Hi Patrick,

On Wed, 2009-07-15 at 08:36 -0400, Patrick Doyle wrote:
> There, was that subject sufficiently obtuse to grab your attention? :-)
> 
> I would like to have several different stylesheets for my application
> that may be selected dynamically as the user navigates through my
> site.  

> What is the most elegant way to do a similar thing in RoR?  Obviously,
> the "on each page" part goes into the application layout.

Since Rails allows you to specify the layout to render on a per
controller / per action level the easiest approach might be to have
several layouts.  Easy, but it could be a performance-detractor as it
would involve a reload of your JS too.

Another approach would be to make your CSS selectors page-specific.  For
example, you could structure your CSS like:

div#login_page {font-size: 16px;}
div#shopping_cart_page{font-size: 12px;}
etc.

And when you render, use controller.controller_name or
controller.action_name, or a combination, to control the html id.

<div id="#{controller.controller_name}_page">

I'm sure there are other, perhaps cleaner approaches.
HTH,
Bill



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to