我越來越想在本地預編譯我的資產鏈輪錯誤鏈輪:: NotImplementedError:自定義asset_path幫手未實現
RAILS_ENV=production bundle exec rake assets:precompile
rake aborted!
Sprockets::NotImplementedError: Custom asset_path helper is not implemented
Extend your environment context with a custom method.
environment.context_class.class_eval do
def asset_path(path, options = {})
end
end
/Users/cman/.rvm/gems/[email protected]/gems/sprockets-3.6.0/lib/sprockets/context.rb:198:in `asset_path'
/Users/cman/.rvm/gems/[email protected]/gems/sprockets-3.6.0/lib/sprockets/context.rb:218:in `font_path'
/Users/cman/.rvm/gems/[email protected]/gems/font-awesome-rails-4.6.1.0/app/assets/stylesheets/font-awesome.css.erb:15:in `_evaluate_template'
我不能爲我的生命弄清楚爲什麼發生這種情況時,以下 - 任何建議如何解決將不勝感激!
更新
我能只有當我添加一個初始化具有以下預編譯:
Rails.application.assets.context_class.class_eval do
def asset_path(path, options = {})
return ''
end
end
但是,如果我這樣做,當我推到我的分級環境中,glyphicons從引導有一個空的路徑,因此不渲染:
font-face{font-family:'Glyphicons Halflings';src:url("");src:url("") format("embedded-opentype"),url("") format("woff"),url("") format("truetype"),url("")
更新2
如果我修改初始化到下面,我得到一個路徑在我的預編譯的glypicons引導資產,但不預編譯Glyphicon文件,它以非編譯的資源路徑:
Rails.application.assets.context_class.class_eval do
def asset_path(path, options = {})
#return ''
"/assets/#{path}"
end
end
@font-face{font-family:'Glyphicons Halflings';src:url("/assets/bootstrap/glyphicons-halflings-regular.eot");src:url("/assets/bootstrap/glyphicons-halflings-regular.eot?#iefix") format("embedded-opentype"),url("/assets/bootstrap/glyphicons-halflings-regular.woff") format("woff"),url("/assets/bootstrap/glyphicons-halflings-regular.ttf") format("truetype"),url("/assets/bootstrap/glyphicons-halflings-regular.svg#glyphicons_halflingsregular")
這是我Gemfile.lock的,因爲它涉及到的資產/鏈輪寶石:
bootstrap-sass (3.1.1.0)
sass (~> 3.2)
rails (4.2.5.2)
actionmailer (= 4.2.5.2)
actionpack (= 4.2.5.2)
actionview (= 4.2.5.2)
activejob (= 4.2.5.2)
activemodel (= 4.2.5.2)
activerecord (= 4.2.5.2)
activesupport (= 4.2.5.2)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.5.2)
sprockets-rails
sass (3.2.19)
sass-rails (4.0.5)
railties (>= 4.0.0, < 5.0)
sass (~> 3.2.2)
sprockets (~> 2.8, < 3.0)
sprockets-rails (~> 2.0)
你能分享一個最小工作示例顯示問題的完整源代碼?一個git回購,例如。 – smathy
您是否按照文檔中的說明導入了自動推進鏈輪? https://github.com/twbs/bootstrap-sass#a-ruby-on-rails –
我認爲Glyphicon問題只是我指定自定義'asset_path'初始值設定項的一個症狀。我真正需要弄清楚的是爲什麼它要求這樣做。如果我創建一個全新的應用程序,它不會要求預編譯。 – cman77