वैकल्पिक रूप से, मैं यही कर रहा हूं। मैं एक आवरण asset_tag
है कि इस तरह इस्तेमाल किया जा सकता बनाने के लिए:
<%= asset_tag 'mystyle', :css %>
<%= asset_tag 'mycode', :js %>
और फिर मैं 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
इस तरह से आप किसी भी तरह से संपत्ति रास्तों को बदल सकते हैं आप चाहते हैं और यह हमेशा आगे संगत होगा।
मुझे यकीन नहीं है कि यह क्यों डाउनवॉट किया गया था। यह एक और स्पष्ट समाधान है और कम हैकी है। – Schrockwell