I want to get the values in:
New
-> Type
-> Version
I Have this setup:
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
How can I access @new.type.version.first
?
Thanks!
Try:
class New < ActiveRecord::Base
has_many :versions, through: :type
...
end
@new.versions.first
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.