开发者

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 pr开发者_运维知识库inciples would you keep in mind when creating databases for a CMS?


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


You should check out the popular CMS systems on ruby toolbox

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜