Search code examples
ruby-on-railscssdynamic-css

How do I create dynamic CSS in Rails?


what is the best/most efficient way of creating dynamic CSS with Rails. I am developing an admin area on a site, where I would like a user to be able to customize the style of their profiles(Colour mostly), which will also be saved.

Would you just embed ruby script in the css file? Would you need to change the file extension from css?

Thanks.


Solution

  • Currently there is a lot of options to generate dynamic css in rails.

    You can use less css - is an extension to CSS with extra features.

    Gem Less css for rails provides integration for Rails projects using the Less stylesheet language in the asset pipeline.

    If you are using twitter bootstrap you may check this out less rails bootstrap.

    Also you can use one more CSS extension language Sass for generating CSS. Here is a Saas rails gem.

    Check out Dynamic CSS in Rails and Render Rails assets to string blog posts and article about Asset Pipeline

    Related SO questions: