My database structure consists of Store, Book, BookStore and Address
class Store < ActiveRecord::Base
has_many :books, :through => :book_stores
acts_as_mappable :through => :addresses
class Address < ActiveRecord::Base
class Book < ActiveRecord::Base
has_many :stores, :through => :book_stores
Join table for many to many relationship between books and stores
class BookStore < ActiveRecord::Base
Now given a book isbn (which is in the Book model) and a store, I need
to find other stores within 5 miles that have that book.
I have looked around but not quite sure how to bring in the Book and
BookStore models with my GeoKit query on something like
Store.within(5, :origin => @storeaddr).
I am on Rails 3.0.5 and using gem ‘geokit-rails3’
Appreciate any thoughts/pointers.