Hello All,
I am currently looking for the easiest way to search across multiple
models.
Suppose I am implementing an online inventory look-up system. A user
will search for a product and a list of stores within 10 miles that
have that product in stock will be returned.
I have two models: Store and Product. Store contains all the location
information. Product contains all the product information. Store
has_many Products.
I would imagine that I could carry this query out in two steps: 1)
Retrieve a list of all stores within 10 miles. 2) Search for products
within those stores.
This two-step process seems a little klunky. Is there any better way
to do this efficiently in Rails?
I am using GeoKit to calculate distances.
Thanks in advance,
-Tom