Rail4 - 如何进行多级关联?

Rail4 - How To Multi-level Associations?

我想获取以下值:

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

谢谢!

尝试:

class New < ActiveRecord::Base
  has_many :versions, through: :type
  ...
end

@new.versions.first