dsp_099
dsp_099

Reputation: 6121

Ruby on Rails Databases - how to organize a CMS?

I've a couple of questions.

I'm making a rudimentary CMS with Rails to get a hang of it. It's going to have pages, blog posts that belong to certain categories (think wordpress) which admins can add/edit from admin area. I'm a bit shaky on databases and relationships between them, though.

I want admins to have full access to the pages and blog posts; blog posts and pages must be separate entities - pages can go in the menu, while blog posts show up on the blog.

How do I organize this as far as the database relationships go so it's all nice and proper?

pages belongs to and has many categories posts belongs to and has many categories?

Also, in what scenarios is the use of add_index() necessary/advisable?

From a bird's eye view, what principles would you keep in mind when creating databases for a CMS?

Upvotes: 4

Views: 283

Answers (2)

Andrea Pavoni
Andrea Pavoni

Reputation: 5311

think about it in terms of relations:

  • a page belongs_to a category
  • a category has_many pages
  • if you want to add more categories to a page, you can think about tags (check for acts_as_taggable_on gem), it's simpler and clearer to manage ;)

finally, add indexes on columns where you'll need faster/frequent lookups

Upvotes: 2

jspooner
jspooner

Reputation: 11315

You should check out the popular CMS systems on ruby toolbox

Upvotes: 1

Related Questions