data = Program.joins(:program_schedules, :channel).
where(
"program_schedules.start" => options[:time_range],
"programs.ptype" => "movie",
"channels.country" => options[:country]).
where("programs.official_rating >= ?", options[:min_rating]).
group("programs.id").
order("programs.popularity DESC")
此查询仅检索“程序”表(我认为是因为“分组依据”子句)。如何从所有表(程序、programs_schedules、通道)中检索所有数据?
类程序 < ActiveRecord::Base
属于_to :channel
has_many :program_schedules
Ruby on Rails 3.2
PostgreSQL 9.2