1

使用 geokit-rails gem,我有:

Employer.rb模型,具有 lng 和 lat 属性:

has_many :jobs,dependent: :destroy act_as_mappable

Job.rb模型,没有 lng 或 lat

act_as_mappable :through => :employer

如果我Job.within(3, origin: [0, 0])在控制台中尝试,我会收到此错误:

PG::UndefinedTable: ERROR:  missing FROM-clause entry for table "employers"
LINE 2: ...      (ACOS(least(1,COS(0.0)*COS(0.0)*COS(RADIANS(employers....
4

1 回答 1

0

我找到了解决方法:

Job.joins(:employer).within(3, origin: [0, 0])
于 2015-12-31T18:53:30.827 回答