rails引擎中的以下范围:
module GolfApi
class Course < ActiveRecord::Base
scope :club_same_name, -> { Course.joins(:club_location).where('club_locations.name=courses.name')}
end
end
在加载引擎的应用程序中执行时会出现以下错误:
PG::UndefinedTable - ERROR: missing FROM-clause entry for table "club_locations"
LINE 1: ...d" = "golf_api_courses"."club_location_id" WHERE (club_locat...
我该如何解决这个问题?
答案 0 :(得分:0)
where子句由SQL执行而没有使用GolfApi进行命名空间,因此需要在where子句中使用golf_api_前缀表,因此范围应为
scope :club_same_name, -> { Course.joins(:club_location).where('golf_api_club_locations.name=golf_api_courses.name')}