# Best way to organize the DB for my app

**URL:** <https://www.ruby-forum.com/t/best-way-to-organize-the-db-for-my-app/178382>\
**Category:** Rails\
**Created:** [November 3, 2009, 8:15pm UTC](https://www.ruby-forum.com/t/best-way-to-organize-the-db-for-my-app/178382 "2009-11-03T20:15:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![erik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b5ac83/32.png) [@erik](https://www.ruby-forum.com/u/erik)\
**Post date:** [November 3, 2009, 8:15pm UTC](https://www.ruby-forum.com/t/best-way-to-organize-the-db-for-my-app/178382/1 "2009-11-03T20:15:41Z")

</div>

I’m working on an app that allows users to customize an HTML design  
template to suit their needs. The user will be able to customize css  
through a graphical interface and then output an HTML for their usage.

The basic idea is that each ‘design’ would have a variety of canned  
‘styles’ or the user can create a ‘custom’ one. My current thinking on  
the DB was that I would have a something like the following:

Designs - has many styles (columns: name, HTML, ?)  
Styles - belongs to design (columns: name, HTML, ?)  
Users (name, password, ?)

My questions are as follows.

First what columns do I need to add to my DB?

I will be displaying the current design (the one that the user is  
customizing) on the lower portion of the page as the user makes changes.  
They will be able click a button to update the preview as they move  
through the customization. Where should I store these HTML pages that  
user can customize? Should I load all the HTML into a DB and then when a  
user wants to customize one, create a copy associated with that user and  
allow them to customize that version?

If the user is basically editing css through a GUI, should I be storing  
each value in a DB (i,e, heading font-size= 2em, heading color=red, etc)  
and then use erb in my html design to reflect whatever the user has  
selected? So when they click the preview I would just pull the various  
css values from the DB and dump them into that html file when it’s  
displayed for them.

btw, I’m thinking of dumping the css inline so the user will have  
everything in one final HTML file.

Any thoughts on how to proceed would be great. If you haven’t figured it  
out by now, I’m noob at rails…

---

<div class="post-metadata">

**Author:** ![erik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b5ac83/32.png) [@erik](https://www.ruby-forum.com/u/erik)\
**Post date:** [November 3, 2009, 10:19pm UTC](https://www.ruby-forum.com/t/best-way-to-organize-the-db-for-my-app/178382/2 "2009-11-03T22:19:50Z")

</div>

Interesting design. My two cents are that you should avoid putting  
the html and css in the database, as you’ll likely see performance  
problems as your site grows. Instead, I would recommend you store the  
custom html and css in discrete files on the filesystem. I don’t know  
of any plugins/gems out there to handle writing to disk (maybe  
Paperclip? [GitHub - thoughtbot/paperclip: Easy file attachment management for ActiveRecord](http://github.com/thoughtbot/paperclip)), but you may want  
to take inspiration from Thoughtbot’s High Voltage plugin (http://  
[GitHub - thoughtbot/high\_voltage: Easily include static pages in your Rails app.](http://github.com/thoughtbot/high_voltage)) to load the needed design file  
once it’s created.

Hope this helps some. Best of luck!  
Jeff

On Nov 3, 2:15 pm, Erik P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
