I need to override the name of a relation, here is my model:
class User < ActiveRecord::Base
has_many :class_rooms_member_ships
has_many :class_rooms
has_many :class_rooms, :through=> :class_rooms_member_ships
end
now, I need another name to use when I want to get class_rooms :through=> :class_rooms_member_ships
how can I achieve this:
user.class_rooms
user.class_rooms_through
Any idea ?
has_many :classrooms_though_memberships, :through=> :class_rooms_member_ships,
:class_name => 'ClassRoom',
:foreign_key => 'class_room_id',
:source => :class_room
This should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With