From: Aldric Giacomoni <"aldric[remove]"@...> Date: 2009-03-31T23:44:48+09:00 Subject: Re: activerecord query building question Mark Thomas wrote: >>> RefPhysLocation.find_all_by_state("OH").each do |location| >>> puts location.refphys.name >>> end >>> >> That would probably work really well in a Rails app, but I get a >> nomethoderror when I try that.. Maybe there's something else I need to >> do before those methods will work >> > > Yes, you have to change the methods to match your database. You did > not provide a schema, so I just used examples. find_all_by_state won't > work if you don't have a state field. You'll have to change > find_all_by_state to find_all_by_zip or whatever find criteria you > will use to determine the area. You'll also have to change > refphys.name to actual attribute(s) of a RefPhys. > Right- I tried the following, which works for my schema (by which I mean, there is a 'City' column in the refphyslocation table): RefPhysLocation.find_all_by_City("Mineola").each do |location| puts location.refphys.fullname end and.. the first bit works (I'd forgotten to capitalize 'city' before).. But I now get 'uninitialized constant RefPhysLocation::Refphys' . I guess there's something I didn't set up properly :/ Do you have any idea what? (I know, I should rtfm and google it.. I don't have time right now, because our mail server at work almost blew up). Thanks for getting me this far at least :)