Jarek Plonski
2011-Aug-20 13:21 UTC
Newbie: Different context and associations for one model
Hi I have models (User and Meeting) like this: # == Schema Information # # Table name: users # # id :integer not null, primary key # name :string(255) # email :string(255) # created_at :datetime # updated_at :datetime # class User < ActiveRecord::Base has_many :participations has_many :meetings, :through => :participations has_many :lectures, :class_name => "Meeting" attr_accessible :name, :email ----------------------------------------------------------------- and: # == Schema Information # # Table name: meetings # # id :integer not null, primary key # starts_at :datetime # ends_at :datetime # title :string(255) # description :text # place :string(255) # tutor :string(255) # total_places :integer # google_event_id :string(255) # google_sync_status :string(255) # created_at :datetime # updated_at :datetime # class Meeting < ActiveRecord::Base # it allows tracking changes in models - see declaration of validations include ActiveModel::Dirty has_many :participations has_many :users, :through => :participations belongs_to :tutor, :class_name => "User", :foreign_key => "user_id" -------------------------------------------------- and then I can find a tutor for a meeting but not the lectures for the user. Should I make a migration containing: add_column :meetings :references, :user_id (or tutor_id) ??? Will appreciate any suggestions Cheers -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.