triggering a query within a loop

in the controller
@movie = Movie.find(:all, :order => "title")
movie_filed = @movies.movie_files

Off course, you need to define the model first:
class MovieFile < ActiveRecord::Base
  belongs_to :movie
end

class Movie < ActiveRecord::Base
  has_many :movie_files
end