Open simkessy opened 9 years ago
I solved it doing this:
@search = Availability.joins{facility.venue.activities}
.where{
(activities.id == s_activity) &
(booking_id == nil) &
(start_time >= s_start_time ) &
(end_time <= s_end_time ) &
(facility.venue_id.in near_by_venues)
}
.order{start_time.desc}
If anyone has any suggestions on how I could improve this, that would be great. Thanks.
I'm trying to filter results based on an array of models
I have 4 models: Venues, Facility, Availability and Activities.
This is the squeel I put together to return Availabilities:
I'm trying to figure out how to filter the results based on an array of Venues which are in proximity to the location entered.
I can get a list of Venues using geocoder gem:
venues = Venue.near("Some location")
, how would I add it above to get Availabilities only from the returned venues?