I have this models:
class Student < ActiveRecord::Base
has_many :tickets
has_many :movies, through: :tickets
end
class Movie < ActiveRecord
As described by Nermin you're trying to request a collection of children, from a collection of children.
You could use collect to gather the students from the companies along the lines of:
@movie.cinema.companies.collect(&:students).flatten.uniq
But I think you would do better to add a scope to your Student model along the lines of:
scope :for_companies, ->(_companies) {joins(:companies).where(company: _companies)}
Called with Student.for_companies(@movie.cinema.companies)
Disclaimer: untested, but should be a starting point!