我有一个User
模型,它通过对模型的委托获取诸如 first_name、last_name 等属性Profile
:
delegate :first_name, :last_name,
to: :profile
我希望能够搜索属于用户的另一个模型,服务。
如何在我的Service
模型中设置 pg_search_scope 配置,以便可以搜索 first_name、last_name?这是我目前拥有的,但它不起作用。
pg_search_scope :search_full_text,
:against => {
:name => 'A',
:description => 'B',
},
:using => {
:tsearch => {:dictionary => "english"}
},
:associated_against => {
:skills => [:name],
:user => [:first_name, :last_name]
}
我收到此错误:
ActiveRecord::StatementInvalid in SearchController#show
PG::Error: ERROR: column users.first_name does not exist
LINE 1: ...ER JOIN (SELECT "services"."id" AS id, string_agg("users"."f...