Created
June 20, 2014 06:56
-
-
Save anonymous/5737b58edb271428ffdd to your computer and use it in GitHub Desktop.
Rails selective loading of assets based on current controller/action name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def load_assets | |
@stylesheets, @javascripts = [], [] | |
[controller_path, "#{controller_path}/#{action_name}"].each do |i| | |
@stylesheets << "pages/#{i}" if File.exists? "#{Rails.root}/app/assets/stylesheets/pages/#{i}.css.scss" | |
@javascripts << "pages/#{i}" if File.exists? "#{Rails.root}/app/assets/javascripts/pages/#{i}.js.coffee" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment