如何解决涉及多个模型的Geokit查询
| 我的数据库结构包括商店,书,书店和地址,如下所示。class Store < ActiveRecord::Base
has_many :book_stores
has_many :books,:through => :book_stores
has_many :addresses
acts_as_mappable :through => :addresses
end
class Address < ActiveRecord::Base
belongs_to :store
acts_as_mappable
end
class Book < ActiveRecord::Base
has_many :book_stores
has_many :stores,:through => :book_stores
end
# Join table for many to many relationship between books and stores
class BookStore < ActiveRecord::Base
belongs_to :book
belongs_to :store
end
现在,有了书isbn(在Book模型中)和一家商店,我需要在5英里内找到其他拥有该书的商店。
我环顾四周,但不太确定如何在诸如Store.within(5,:origin => @storeaddr)之类的GeoKit查询中引入Book和BookStore模型。
我在Rails 3.0.5上并使用gem \'geokit-rails3 \'
赞赏任何想法/指标。
-S
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。