Ruby on Rails Tuesday, May 24, 2016

I think it depends on your use case. Things to consider:

1. Selecting all comments of a user via 1 association or N associations (and 1 vs N queries).
2. Storing more data in the table (:commentable_type).
3. Maintaining and testing one model vs testing N models.

I think the biggest problem with separate comment models is that references from other models are the fact that you need N times more associations to reference a comment (e.g. user.post_comments, user.picture_comments, ... instead of user.comments).

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAA6WWt-7%3DrrEpcs%2B84m9EiDCZa-XDKDAfAKrnuMvCKxkfCgUjg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment