Brian V. Hughes
2005-Aug-04 16:54 UTC
Finding rows in table a with zero related rows in table b, part ii
OK. After a little more digging in MySQL''s manual on SubSelects,
I''ve
changed the finder_sql entry in my model declaration:
class District < ActiveRecord::Base
has_many :interviewers,
:order => "lname, fname"
has_many :applicants
has_many :unassigned_applicants,
:class_name => "Applicant",
:finder_sql => "select a.* from applicants a left join
applicants_interviewers ai " +
"on a.id = ai.applicant_id where ai.applicant_id is null"
end
Running that SQL through the mysql command-line tool returns exactly the
data I''m looking for. However, in my district_controller.rb file,
I''ve
got this method:
def unassigned_list
@dist = District.find( params[:dist_id] )
@applicants = @dist.unassigned_applicants.find( :all )
@sub_title = "Unassigned Applicants (" + @applicants.size.to_s +
")"
render :template => "district/app_list"
end
When I go to the page that calls this method, it throws back this error:
NoMethodError in District#unassigned_list
undefined method `expects_array?'' for #<Array:0x2271d04>
I have no idea what this is trying to tell me. What is the
expects_array? method doing? Or trying to do?
-Brian
