rails, how to alias a relation in model?

activerecord, ruby-on-rails, ruby-on-rails-3

Solution

has_many :classrooms_though_memberships, :through=> :class_rooms_member_ships, 
                                     :class_name => 'ClassRoom', 
                                     :foreign_key => 'class_room_id',
                                     :source => :class_room

This should work.

Problem

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 ?

Original source

Related problems