I have a relations question. I have an events table where each event is
owned by a user. So…
class Event < ActiveRecord::Base
belongs_to :user
end
And a user…
class User < ActiveRecord::Base
has_many :events
end
But, I also have an attendance_lists table so that other users can say
they are attending an event (or not attending). So…
class AttendanceList < ActiveRecord::Base
belongs_to :users
belongs_to :events
end
But now, if I’m going to add the relations to the user and event
models, it would seem I would have…
class Event < ActiveRecord::Base
belongs_to :user
has_many :attendance_lists
has_many :users, :through => :attendance_lists
end
class User < ActiveRecord::Base
has_many :events
has_many :attendance_lists
has_many :events, :through => :attendance_lists
end
My question is whether ActiveRecord will be able to differentiate,
using the relations above, the events a user is in charge of and events
a user is attending. In the user model, will having two has_many
:events, even though one has a :through clause, confuse ActiveRecord?
Am I confused and not including something I should be?
I have a relations question. I have an events table where each event is
owned by a user. So…
class Event < ActiveRecord::Base
belongs_to :user
end
And a user…
class User < ActiveRecord::Base
has_many :events
end
But, I also have an attendance_lists table so that other users can say
they are attending an event (or not attending). So…
class AttendanceList < ActiveRecord::Base
belongs_to :users
belongs_to :events
end
But now, if I’m going to add the relations to the user and event
models, it would seem I would have…
class Event < ActiveRecord::Base
belongs_to :user
has_many :attendance_lists
has_many :users, :through => :attendance_lists
end
class User < ActiveRecord::Base
has_many :events
has_many :attendance_lists
has_many :events, :through => :attendance_lists
end
My question is whether ActiveRecord will be able to differentiate,
using the relations above, the events a user is in charge of and events
a user is attending. In the user model, will having two has_many
:events, even though one has a :through clause, confuse ActiveRecord?
Am I confused and not including something I should be?