DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Autoinclude CSS Files By Controller/Action Name
def stylesheet_auto_link_tags
stylesheets_path = "#{RAILS_ROOT}/public/stylesheets/"
candidates = [ "#{controller.controller_name}",
"#{controller.controller_name}_#{controller.action_name}" ]
candidates.inject("") do |buf, css|
buf << stylesheet_link_tag(css) if FileTest.exist?("#{stylesheets_path}/#{css}.css")
buf
end
end
Compliments of Dema Note: Anyone interested in this might also be interested in the bundled_resource plugin (google for it).






Comments
Snippets Manager replied on Mon, 2012/05/07 - 2:13pm
Snippets Manager replied on Mon, 2012/05/07 - 2:13pm