Hi,
I have a people table which has a first_name,last_name as varchar
fields and a salutation table which also has first_name, last_name as a
boolean field.
class People
belongs_to :salutation
end
class Salutation
has_many :people
end
The problem i have is when i try to eager load using
@people = Person.find_all_by_id(params[:id],:include=>:salutation)
I get an error “ambiguous column last_name and first_name”
how can i solve this problem without having to change the name of the
column in the salutation table.
Thank you.
On Jun 22, 10:37 am, Ank Ag [email protected] wrote:
The problem i have is when i try to eager load using
@people = Person.find_all_by_id(params[:id],:include=>:salutation)
I get an error “ambiguous column last_name and first_name”
are you also specifying some conditions somewhere? typically this
means that instead of writing first_name = ‘foo’ you need to write
salutations.first_name = ‘foo’ (or the other way round if your
conditions should apply to the person’s first name).
Fred
Frederick C. wrote:
On Jun 22, 10:37�am, Ank Ag [email protected] wrote:
The problem i have is when i try to eager load using
@people = Person.find_all_by_id(params[:id],:include=>:salutation)
I get an error “ambiguous column last_name and first_name”
are you also specifying some conditions somewhere? typically this
means that instead of writing first_name = ‘foo’ you need to write
salutations.first_name = ‘foo’ (or the other way round if your
conditions should apply to the person’s first name).
Fred
Hi Thank you… In the :order clause i wrote :order=>‘last_name’ and as
you mentioned it should have been :order=>‘people.last_name’
Thanks.