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
-~----------~----~----~----~------~----~------~--~---

Reply via email to