Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

render different stylesheets for different partials in ruby

Hi,

I'm updating the frontend of a rails project. And I would like every new page that's built to a render a new stylesheet to the old one.

How would be the best way to do this?

Can I check for the partials name and and load a stylesheet a if it's name matches x y or z

I was thinking something like this

Check if partial name is x y or z if it is load new stylesheet a else load stylesheet b

I just don't know how i would actually write this.

Thanks!!

1 Answer

Kevin Korte
Kevin Korte
28,149 Points

What's the reason for adding this layer of complexity? I could see wanting to use different stylesheets based on controllers or actions, (ie. front end vs admin), but I don't know why you would need something with this much logic for partials.

Off the top of my head, I don't know, because I haven't spent much time messing with the asset pipeline. What decided what partial gets loaded?

So the issue is that. The site is getting a redisgn. The current style sheet is out of control to say the least.

So moving forward I would like to start rebuilding a couple of pages, but have them load a new stylesheet for the new design.

Does this make sense? Should I do something different completely? Does anyone have any better ideas.