Reputation: 914
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!
Upvotes: 1
Views: 118
Reputation: 1050
Try:
class New < ActiveRecord::Base
has_many :versions, through: :type
...
end
@new.versions.first
Upvotes: 2