title: Rails "undefined method for ActiveRecord_Associations_CollectionProxy"
body: <p>I have this models:</p>
  
  <pre><code>class Student &lt; ActiveRecord::Base
  
      has_many :tickets
      has_many :movies, through: :tickets
  
  end
  
  
  class Movie &lt; ActiveRecord::Base
  
      has_many :tickets, dependent: :destroy
      has_many :students, through: :tickets
      belongs_to :cinema
  
  end
  
  
  class Ticket &lt; ActiveRecord::Base
  
      belongs_to :movie, counter_cache: true
      belongs_to :student
  
  end
  
  
  class Cinema &lt; ActiveRecord::Base
  
      has_many :movies, dependent: :destroy
      has_many :students, through: :movies
  
      has_many :schools, dependent: :destroy
      has_many :companies, through: :yard_companies
  
  end
  
  
  class School &lt; ActiveRecord::Base 
  
      belongs_to :company
      belongs_to :student
      belongs_to :cinema, counter_cache: true
  
  end
  
  
  class Teacher &lt; ActiveRecord::Base
  
      belongs_to :movie, counter_cache: true
      belongs_to :company
  
  end
  
  
  class Contract &lt; ActiveRecord::Base
  
      belongs_to :company
      belongs_to :student
  
  end
  
  
  class Company &lt; ActiveRecord::Base
  
      has_many :teachers
      has_many :movies, through: :teachers
  
      has_many :contracts
      has_many :students, through: :contracts
  
  end
  </code></pre>
  
  <p>If I write this in my <strong>movies_controller.rb</strong>:</p>
  
  <p><code>@students = @movie.cinema.companies.students.all</code></p>
  
  <p>I have this error:</p>
  
  <p><strong>undefined method 'students' for #Company::ActiveRecord_Associations_CollectionProxy:0x00000007f13d88></strong></p>
  
  <p>If instead I write this:</p>
  
  <p><code>@students = @movie.cinema.companies.find(6).students.all</code></p>
  
  <p>it shows me the correct students in my select_collection.</p>
  
  <p><strong>How to better understand this process?</strong></p>
  
  <p><strong>UPDATE</strong>:</p>
  
  <p>I need the collection_select of every students in companies of a cinema of this movie.</p>
  
  <p>How to write?</p>