我想获取值:
New
- > Type
- > Version
我有这个设置:
class New < ActiveRecord::Base
has_one :type
end
class Type < ActiveRecord::Base
belongs_to :new
has_many :versions
end
class Version < ActiveRecord::Base
belongs_to :type
end
如何访问@new.type.version.first
?
谢谢!
答案 0 :(得分:2)
尝试:
class New < ActiveRecord::Base
has_many :versions, through: :type
...
end
@ new.versions.first