In alternativa, ecco cosa sto facendo. Creo un wrapper asset_tag
che può essere utilizzato in questo modo:
<%= asset_tag 'mystyle', :css %>
<%= asset_tag 'mycode', :js %>
E poi mi definisco nel application_helper
:
module ApplicationHelper
# here is where you define your paths
# in this case, paths will be '/css/mystyle.css' and '/js/mycode.js'
def asset_path(asset, type)
return "/css/#{asset}.css" if type == :css
return "/js/#{asset}.js" if type == :js
end
def asset_tag(asset, type)
return stylesheet_link_tag asset_path(asset, type) if type == :css
return javascript_include_tag asset_path(asset, type) if type == :js
end
end
In questo modo è possibile modificare i percorsi di attività in qualsiasi modo si desidera e sarà sempre compatibile con il futuro.
Non sono sicuro del motivo per cui questo è stato downvoted. Questa è una soluzione più esplicita ed è meno hacky. – Schrockwell