I have this models:
class Student < ActiveRecord::Base
has_many :tickets
has_many :movies, through: :tickets
end
class Movie < ActiveRecord
@students = @movie.cinema.companies.students.all to explain why this throws error
@movie.cinema will give you cinema of the movie
@movie.cinema.companies will give you a list of companies for that cinema as an ActiveRecord_Association_CollectionProxy
Then when you call students on the CollectionProxy of companies via @movie.cinema.companies.students it throws an error because CollectionProxy has no such method.
@students = @movie.cinema.companies.find(6).students.all will work because you get a list of companies, then from that list you find a single company with id 6 and list all students for that single company.