# Generating a css file from ruby code

**URL:** <https://www.ruby-forum.com/t/generating-a-css-file-from-ruby-code/165627>\
**Category:** Rails\
**Created:** [April 15, 2009, 9:18pm UTC](https://www.ruby-forum.com/t/generating-a-css-file-from-ruby-code/165627 "2009-04-15T21:18:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gavin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/439d5e/32.png) [@gavin](https://www.ruby-forum.com/u/gavin)\
**Post date:** [April 15, 2009, 9:18pm UTC](https://www.ruby-forum.com/t/generating-a-css-file-from-ruby-code/165627/1 "2009-04-15T21:18:04Z")

</div>

Hi all!

I’m playing around with an app at the moment in which users can  
specify their own style settings for the majority of the HTML on their  
profile through selecting some form options. Alternatively they can  
upload a stylesheet of thier own if they have CSS experience.

I thought of a couple of different way of doing this but the most  
logical way seemed to be creating a seperate stylesheet for each user  
in the model and calling this stylesheet when the page is rendered.

I’ve created a plugin which takes a ruby hash and creates a hunk of  
text which is then written to a css file.

[http://github.com/GavinM/css\_writer/tree/master](http://github.com/GavinM/css_writer/tree/master)

I’m just curious as to whether anyone can think of a better way of  
doing this?

Also - this is my first plugin. I would welcome any feedback/  
constructive criticism

thanks

-🙂
