Created
March 20, 2011 14:04
-
-
Save srih4ri/878336 to your computer and use it in GitHub Desktop.
Call it with <%= stylesheet_link_tag(*get_stylesheets) %> in your layouts file
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 get_stylesheets | |
styles_path = "#{Rails.root}/public/stylesheets" | |
controller_name = controller.controller_path | |
action_name = controller.action_name | |
if File.exists? "#{styles_path}/#{controller_name}/#{action_name}.css" | |
"#{controller_name}/#{action_name}" | |
elsif ["create","edit","update"].include? action_name and File.exists? " #{styles_path}/#{controller_name}/new.css" | |
"#{controller_name}/new" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment