A nested set seems a little overkill. I realized I could make two polymorphic associations: one in Comments, and one in the join table for commentable_subscribers.
I'm not sure if that's a better plan or not, though. I like that I can enforce foreign key constraints when I use the extra CommentGroup table. On Oct 15, 6:49 pm, Eric <[email protected]> wrote: > I think you are. I'd make Comment polymorphic, a nested set, and > has_many :subscribers, which should be based on the top parent of the > comment thread. > > -eric > > On Oct 15, 4:32 pm, Scott Johnson <[email protected]> wrote: > > > Am I reinventing polymorphic associations? > > > I have a fairly standard blog with comments model, with the following > > additions: > > > (1) Multiple models can accept comments (blog post, bug report, etc). > > > (2) Each group of comments has a list of subscribers that will be > > emailed when a new comment is posted. > > > Requirement (1) leads me to a polymorphic association. But I can't see > > how to fit requirement (2) into that. Each group of comments needs > > some place to store the list of subscribers. > > > So I added a CommentGroup table. > > > class BlogPost < ActiveRecord::Base > > belongs_to :comment_group > > end > > > class BugReport < ActiveRecord::Base > > belongs_to :comment_group > > end > > > class CommentGroup < ActiveRecord::Base > > has_one :blog_post > > has_one :bug_report # note: one or the other will be nil > > > has_and_belongs_to_many :subscribers > > end > > > class Comment < ActiveRecord::Base > > belongs_to :comment_group > > end > > ---- > > > But now table :comment_group only has one field: id. And that just > > seems wrong to me. > > > Is that bad? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

