class Event &lt; ActiveRecord::Base  <br>
&nbsp; belongs_to&nbsp; :venue <br>
&nbsp; belongs_to&nbsp; :category<br>
end<br>
<br>
class Venue &lt; ActiveRecord::Base<br>
&nbsp; belongs_to&nbsp; :city <br>
end<br>
<br>
class City &lt; ActiveRecord::Base<br>
&nbsp; belongs_to&nbsp; :state<br>
end<br>
<br>
I want to retrieve all event records belonging to a state. Coming from hibernate background I tried something like this:<br>
<br>
&nbsp;def self.list_for_a_state(state_id)<br>
&nbsp;&nbsp;&nbsp; find_by_sql([&quot;select e.* from venues v, events e where v.city.state_id= ? and e.venue_id = <a href="http://v.id">v.id</a>&quot;,state_id])<br>
&nbsp;end<br>
<br>
Error: Unknown table 'v.city' in where clause<br>
<br>
How do I handle this case?<br>
<br>
Thanks.<br>
<br>