I am building Rails 3 app and I need some help for my database design. I have model called Post. Posts also contains Tutorial, Example and Comments.
Comments has own model, but I was wondering should I build own models for Tutorials and Examples?
Tutorials and examples contains lot of links. Now should I build it like this?
Post
has_one :tutorial
has_one :example
Tutorial
belongs_to :post
Example
belongs_to :post
Or should I just put tutorial and example fields in Posts table? Tutorial and example are shown only when user views post.
Do
TutorialandExamplehave many attributes (and associated logic)? I’d say they should have their own model unless they only have one attribute, in which case a field in thePosttable would do.As an aside, if you are able to
Commenton more than one model consider using a polymorphic association (Commentbelongs_to :postable, :polymorphic => true):http://guides.rubyonrails.org/association_basics.html#polymorphic-associations