How do I create dynamic CSS in Rails?

后端 未结 6 1981
Happy的楠姐
Happy的楠姐 2020-12-13 16:21

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

6条回答
  •  星月不相逢
    2020-12-13 16:44

    You can use ERB with CSS, you just need to render css in the controller. However, for such a heavily requested resource, I do not recommend generating this every time. I would store the users stylesheet in memcached or redis, and recall from it when the page loads, rather than rerendering the file each time. When they update their style, you can expire the cache, just make sure it gets rebuilt when the page renders.

提交回复
热议问题