Hi, Phone.find(:all, :conditions=>["area_code in ? and number in ?",(555,533),(533,12345678)])
Regards, Vishal Singh Ruby On Rails Developer On Tue, Apr 24, 2012 at 11:07 AM, Rafael C. de Almeida <[email protected] > wrote: > On Apr 24, 1:55 am, vishal singh <[email protected]> wrote: > > hi, > > > > Make a two model, Lawyer and Phone then in lawyer model add has_any > :phones > > and in phone model add belongs_to :lawyer > > > > then find lawler like > > > > @lawyer = Lawyer.find(1) 1 is id in lawyer table > > > > then write > > @lawyer.phones (it will fetch all the phone number of this lawyer havind > > id =1) > > you can add where clause > > @lawyer.phones.where(:area_code => area_code, :number => > > number) > > The thing is that I have a list of possible area codes and numbers. > The way you wrote it won't allow me to search for lawyers who have a > phone inside my list. Unless, I do multiple queries. I suppose there's > no way to translate select * from phones where (area_code, number) in > (('555', '1234564'), ('533', '12345678')) into activerecord. Doing a > for like the one I wrote before is probably the way to go. > > -- > 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 [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

