Forum: Ruby on Rails How do you associate "Notes" to many models?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2c2f3ce7125411ff78a1d3e902aa2a4d?d=identicon&s=25 Bob Sanders (adistarmid)
on 2008-10-16 02:30
I'm trying to find the best way to associate notes to many models. I
have a table called notes, and the tables I wanted associated to those
notes are:

players
teams
parents

To accomplish it, would my notes database column just have the
following:

Note
---------
body:string
player_id:integer
team_id:integer
parent_id:integer

That does seem messy, so I don't know if that's correct. Is there a
better approach to associate notes to many models?
23e4fc3add5443f51e55663cfc245d24?d=identicon&s=25 Erol Fornoles (Guest)
on 2008-10-16 03:04
(Received via mailing list)
On Oct 16, 8:30 am, Bob Sanders <rails-mailing-l...@andreas-s.net>
wrote:
>
> Posted viahttp://www.ruby-forum.com/.
Does a note need to be associated with only one of the 3 tables for
each instance? If yes, take a look at has_many_polymorphs.

http://m.onkey.org/2007/8/14/excuse-me-wtf-is-polymorphs
http://blog.evanweaver.com/files/doc/fauna/has_man...
This topic is locked and can not be replied to.