와 여기 내 STI 모델입니다 :레일 3 hasMany의를 통해이 STI
class User < ActiveRecord::Base
end
class Athlete < User
has_many :sports, :through => :user_sports
has_many :user_sports
end
class Coach < User
end
UserSports
테이블 user_id
및 sport_id
있다 ...하지만이 실행 생성
athlete = Athlete.all.last
athlete.sports
SQL을 user_id
대신 athlete_id
을 사용하려고합니다 ... 내가 여기서 잘못하고있는 것이 확실하지 않습니다 ... 어떤 제안이 좋을 것입니다!