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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Jun 22, 10:37 am, Ank Ag <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> 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> how can i solve this problem without having to change the name of the > column in the salutation table. > > Thank you. > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On Jun 22, 10:37�am, Ank Ag <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> 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). > > FredHi Thank you... In the :order clause i wrote :order=>''last_name'' and as you mentioned it should have been :order=>''people.last_name'' Thanks. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---