Hi, I have a has_and_belongs_to_many relationship between games and users in my project. Now i want to save the rank a user had each game he played. It seems obvious to add a field in the table linking the two holding the rank. Only im having problems making this happen. Creating a model of this table makes ruby think the corresponding table is game_users, and ruby also needs an id field in this table. Probably some really easy settings to fix this, but i cant find it anywhere so any help would be appreciated. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Uli, If you want to have some properties in your association, you may create a model for that. Remove your games_users table (I guess from your Game or User migration file), and create a model. Add game_id, user_id and rank in your migration file. Then add belongs_to :user and belogns_to :game in this model. Last, add has_many in User and Game model. If you want to access users from Game and games from User, just add an has_many :through (check the doc). Regards, Jean-Etienne http://www.woa.hu -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jean is right. If you want to include information with your associations, you can''t use HABTM anymore. You have to make your HABTM table into a normal table and associate the other tables with each other ":through" that table instead. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---