2016-04-06 34 views
0

içine Sembol örtülü hiçbir dönüşüm:Raylar yardımcı `String` ben Middleman için Gulp Starter Raylar yardımcıları taşıma ediyorum ancak aşağıdaki hatayı alıyorum

no implicit conversion of Symbol into String değilim Ruby /middleman-gulp-starter/helpers/gulp_asset_helper.rb: in join, line 14

ilgili Neden bu işe yaramadığını anlamak için Rails ve Middleman arasındaki farkların emin.

module GulpAssetHelper 
    def gulp_asset_path(path, type = nil) 
    rev_manifest = nil 

    # In development, check for the manifest every time 
    if !config[:build] 
     rev_manifest = JSON.parse(File.read(REV_MANIFEST_PATH)) if File.exist?(REV_MANIFEST_PATH) 
    # In production, use the manifest cached in initializers/gulp.rb 
    else 
     rev_manifest = REV_MANIFEST if defined?(REV_MANIFEST) 
    end 

    root = GULP_CONFIG['root']['dest'].gsub(/(.*)build\//, '/') 
    asset_path = type ? File.join(GULP_CONFIG['tasks'][type]['dest'], path) : path # LINE 14 
    asset_path = rev_manifest[asset_path] if rev_manifest 
    asset_path = File.join(root, asset_path) 
    File.absolute_path(asset_path, '/') 
    end 

    def gulp_js_path(path) 
    gulp_asset_path(path, 'js') 
    GULP_CONFIG 
    end 

    def gulp_css_path(path) 
    gulp_asset_path(path, 'css') 
    end 

    def gulp_image_path(path) 
    gulp_asset_path(path, 'images') 
    end 

    def sprite(id, classes = "", viewBox = "0 0 24 24") 
    "<svg class='sprite -#{id} #{classes}' aria-hidden='true' preserveAspectRatio viewBox='#{viewBox}'><use xlink:href='#{gulp_image_path('sprites.svg')}##{id}' /></use></svg>".html_safe 
    end 
end 

rev ve yapılandırma ithalat dosyası:

GULP_CONFIG = JSON.parse(File.read('gulpfile.js/config.json')) 
REV_MANIFEST_PATH = File.join(GULP_CONFIG['root']['dest'], 'rev-manifest.json') 

if File.exist?(REV_MANIFEST_PATH) 
    REV_MANIFEST = JSON.parse(File.read(REV_MANIFEST_PATH)) 
end 

Örnek rev-manifest.json dosyası:

{ 
    "images/middleman-logo.svg": "images/middleman-logo-2e3d8b5ad1.svg", 
    "javascripts/all.js": "javascripts/all-92681c51e741e0e1370c.js", 
    "stylesheets/site.css": "stylesheets/site-9b25f1d1ac.css" 
} 

Ben gulpfile içeriği için doğru bir şekilde okunduğunu biliyoruz çıktı ettik.

Burada tam repo bulabilirsiniz: bu hat üzerinde başarısız gibi https://github.com/craigmdennis/middleman-gulp-starter/tree/4_asset-helpers

+1

Satır 14'te bir hata varsa, lütfen bizim için çizgiyi 14 işaretleyin. – Meier

cevap

1

görünüyor:

asset_path = type ? File.join(GULP_CONFIG['tasks'][type]['dest'], path) : path 

File.join yöntem dizeleri bekliyoruz böylece GULP_CONFIG['tasks'][type]['dest'] veya path olmayan bir dize ama ya sembolü. Bunun gibi bir şey deneyin:

asset_path = type ? File.join(GULP_CONFIG['tasks'][type.to_s]['dest'].to_s, path.to_s) : path.to_s 
+0

Yani (daha fazla hatada olduğu gibi) çalışır, ancak sadece tüm json dosyasını çıktı olarak görünüyor görünüyor – Craig

+0

Tamam, ben gerçek komut dosyası etiketlerini yanlış yapılandırılmış. Bu mükemmel çalışıyor. Teşekkürler. – Craig

İlgili konular