Я хочу создать ассоциацию, подобную этой:
has_many :foos, through: self.attr == 'bar' ? :association1 : :association2
но у меня проблема в том, что я не могу получить доступ к self.attr здесь. Так что я могу сделать?
self.attr
Пожалуйста, помогите !!!
Может быть сделать это как 2 ассоциации:
has_many :association1_foos, through: :association1 has_many :association2_foos, through: :association2 def foos self.attr == 'bar' ? self.association1_foos : self.association2_foos end