Ruby on rails 如何快速加载STI子类上的所有关联
我有这样一个模型层次结构:Ruby on rails 如何快速加载STI子类上的所有关联,ruby-on-rails,ruby,activerecord,ruby-on-rails-5,Ruby On Rails,Ruby,Activerecord,Ruby On Rails 5,我有这样一个模型层次结构: class Activity end class HelloActivity < Activity has_one :hello_activity_details end class WorldActivity < Activity has_one :world_activity_details end 屈服 Association named 'hello_activity_details' not found on WorldActivi
class Activity
end
class HelloActivity < Activity
has_one :hello_activity_details
end
class WorldActivity < Activity
has_one :world_activity_details
end
屈服
Association named 'hello_activity_details' not found on WorldActivity; perhaps you misspelled it?
如何加载详细信息
我知道我可以手动调用预加载程序,但是有没有更惯用的方法呢
“谢谢”如错误所述,看起来像是典型的打字错误
has_one
必须将类关联名称设置为单数
尝试:
类HelloActivity
Association named 'hello_activity_details' not found on WorldActivity; perhaps you misspelled it?
class HelloActivity < Activity
has_one :hello_activity_detail
end
class WorldActivity < Activity
has_one :world_activity_detail
end