Displaying 1 result from an estimated 1 matches for "list_for_a_state".
2006 Jan 31
2
Relationship navigation issue
...longs_to :venue
belongs_to :category
end
class Venue < ActiveRecord::Base
belongs_to :city
end
class City < ActiveRecord::Base
belongs_to :state
end
I want to retrieve all event records belonging to a state. Coming from
hibernate background I tried something like this:
def self.list_for_a_state(state_id)
find_by_sql(["select e.* from venues v, events e where
v.city.state_id=? and
e.venue_id = v.id",state_id])
end
Error: Unknown table ''v.city'' in where clause
How do I handle this case?
Thanks.
-------------- next part --------------
An HTML attachment wa...