Hi,
I actually ran into a problem with includes:
The model:
Company has_many :jobs
Job belongs_to Satus
The code that fails is:
jobs=Job.search(:order => 'ascend_by_status_name',:status_name =>
'approved').all(:conditions => '
companies.id = 5645',:include =>
[:company,:job_status])
I also tried it with named_scopes:
jobs=Job.of_company(5645).search(:order =>
'ascend_by_status_name',:status_name => 'approved').all(:include =>
[:company,:job_status])
and
jobs=Job.of_company(5645).with_includes(:company,:job_status).search
(:order => 'ascend_by_status_name',:status_name => 'approved').all
the error:
table name "status" specified more than once
the SQL statement does a left outer join AND an inner join on status
The "solution" is to pass a :joins => :status to all. If you leave out
any of the querry modifiers (of_company, :order, :status_name) it
works,too.
Is this a known issue? Any workarounds? Tips?
Thanks
Peter