Ah ok,
I had read this document, the reason I didn't find what I was looking
for was that the associations in here were all opposite to my needs, eg
- one of the examples is
time_range = (Time.now.midnight - 1.day)..Time.now.midnight
Client.joins(:orders).where(:orders => {:created_at => time_range})
where a Client presumably has_many orders, and an Order belongs_to a
client.
I was looking for something like as you say:
Event.join(:venue).where(:venue => { :locality => "London" })
where an Event belongs_to a Venue, and a venue has many events. looking
that way round
Unfortunately, the exact line you give returns
undefined method `join' for #<Class:0x104b2fd68>
trying 'joins' instead returns:
SQLite3::SQLException: no such column: venue.locality: SELECT "events".*
FROM "events" INNER JOIN "venues" ON "venues"."id" = "events"."venue_id"
WHERE ("venue"."locality" = 'London')
there definitely is a column in venue called locality!
I think I tried this as part of my searching, but kept getting errors
along these lines.
Is there an easy way to make the query, when an Event belongs_to a
Venue, and I'm searching using an attribute in the Venue model.
Thanks for your help
Mike
--
Posted via http://www.ruby-forum.com/.
--
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.