jaypowers-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Jan-31 04:43 UTC
Relating models question
Hello All, Basically I''m trying to create a model relationship that is used to link (I''m hoping to call it Follows) one model to another. I was hoping to use a polymorphic relationship so I don''t have lots of tables. A structure like below is what I''m shooting for. User.follows.[Model] Where Model is any model that can be followed. I''ve tried a bunch of :though, polymofic senerios, but just can''t seem to get it to work as desired. I would like a User to Follow any other model. Seems like this should be easy to do in ActiveRecord. u = User.find(1) c = Category.find(1) u.follows << c then u.follows.categories would give me all the categories a user follows. Anyone come out there tackle something like this ? Thanks --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---