From: Aldric Giacomoni <"aldric[remove]"@...> Date: 2009-03-31T21:14:48+09:00 Subject: Re: activerecord query building question Mark Thomas wrote: > On Mar 30, 2:30 pm, Aldric Giacomoni <"aldric[remove]"@trevoke.net> > wrote: > >> I have this: >> >> require 'activerecord' >> >> class RefPhys < ActiveRecord::Base >> set_table_name "tbRefPhys" >> has_many :refphyslocations, :foreign_key => "refphysid" >> end >> >> class RefPhysLocation < ActiveRecord::Base >> set_table_name "tbRefPhysLocations" >> belongs_to :refphys, :foreign_key => "refphysid" >> end >> >> I want a list of the refphys names (in refphys) in a specific city (in >> refphyslocation). >> So... >> RefPhys.find(:all, :joins => ['refphyslocation'] .... ? >> >> I don't grok AR yet :/ >> > > It would be something like this: > > 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.