views:

37

answers:

1

Hello,

This is a fairly straightforward question.

I have Users in my Rails3 Application. I want to give each user the ability to customize their stylesheet through a form so they can essentially have their own themes.

I was wondering how I can go about getting this to happen and what is the best way that you have seen it done?

Would I need to use LessCss and if so, can I pass variables from a controller to the lesscss sylesheet?

+3  A: 

Despite that sounding like a terrible idea I guess an easy way to do it would be to add a CSS table and map it to the user with a record for each CSS file. When a new user is created you create new records for each file using the default CSS.

To edit you could present the user with the CSS text on a page with some sample mini-page where they could see the changes happen live. You would then need to load the CSS dynamically which could be a huge hit on your database so you'd want to add some memory to the call to retrieve the CSS.

Again though, this is a horrible idea in my opinion. What happens when the user messes up and then can't use the site because they put in some bad value? They can't change it back because they can't see anything so what do they do? They never come back.

You'd be better off just allowing them to pick from a set of allowed themes. But hey, it's your website, you do with it as you please.

Mike Bethany
Hello Pickle, I understand what your saying and I've been thinking of which way I want to do it. I already understand how to do it the way you suggested with only themes. I may do a middle ground that offers them the ability to change the background colors or colors of some elements through a color picker. I would just have those colors be set inline to override the current css. I appreciate the response. Thanks!
bob