You can use a specific css file for each controller, just called the css file like your controller: app/assets/stylesheets/greetings.css.scss
Also you can use the params[:controller] in your layout to load styles only for a specific controller( I don't know if that is a good practice) like: if params[:controller] == "greeting" end Matt's On Fri, Jun 27, 2014 at 10:30 AM, Gioele Barabucci <[email protected]> wrote: > Hello, > > I would like to use controller-specific stylesheets instead of the usual > `application.css`. So, if a page were rendered by controller Foo it would > include only the stylesheet whose source is `app/assets/stylesheets/foo. > css.scss`. > > I am using Rails 4.0.x. > > I tried replacing > > stylesheet_link_tag('application') > > with > > stylesheet_link_tag(params[:controller]) > > in the default layout as suggested by the assets guide [1] but is not > producing the expected effects. > > The first statement returns > > <link href="/assets/application.css?body=1" … > > while the second returns > > <link href="/stylesheets/foo.css" … > > How can I make my controller-specific stylesheet go through the assets > pipeline? > > Bye, > > [1] http://guides.rubyonrails.org/v4.0.6/asset_pipeline.html > > -- > Gioele Barabucci <[email protected]> > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/rubyonrails-talk/lojv5r%246sn%241%40ger.gmane.org. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CALX-aHo%2BuLiAkqjJxWbEYUNyrJ1FC-HOy0AudEL-nt8FVNaSEg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

