From db to css file?

谁说胖子不能爱 提交于 2019-12-24 02:16:53

问题


I have a small set of css items in a db table that I need to turn into a css file to be included on a page. How can I do this in Rails3?

Is there a way I can call this directly from a stylesheet_link tag? Do I need to go through some ruby to open a file and output it in some directory first? Do I do this in a controller?

The css is actually its own model associated to the item using the css.

I do not know and looking for a solution found little yet, so asking here.

EDIT:

Simple when looked at, I was looking toward a sass or less solution and may still, but this is a simple start


回答1:


I would create a Controller that retrieves the data from the database that uses a View to render the data to a Cascading Style Sheet.

You could then reference the given URL whenever you need to use the resulting stylesheet.




回答2:


This is the easiest way that I have found http://blog.hasmanythrough.com/2007/10/18/simpler-than-dirt-restful-dynamic-css



来源:https://stackoverflow.com/questions/6266129/from-db-to-css-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!