Ruby on rails 使用search_cop进行全球化-未知属性
我试图将Ruby on rails 使用search_cop进行全球化-未知属性,ruby-on-rails,globalize,Ruby On Rails,Globalize,我试图将globalizegem和search\u cop结合使用。在我的模型中,我有: class Museum < ApplicationRecord include SearchCop has_one_attached :hero_image translates :name, :address, :description, :facilities, :hours, :tickets search_scope :search do attributes :
globalize
gem和search\u cop
结合使用。在我的模型中,我有:
class Museum < ApplicationRecord
include SearchCop
has_one_attached :hero_image
translates :name, :address, :description, :facilities, :hours, :tickets
search_scope :search do
attributes :name, :address
options :name, :type => :fulltext
options :address, :type => :fulltext
end
end
可以同时使用Globalize和SearchCop吗?如果是,如何指定要搜索的已翻译字段?要将Globalize与SearchCop一起使用,您需要通过其关联定义已翻译属性。比如:
search_scope :search do
attributes name: "translations.name", address: "translations.address"
options :name, :type => :fulltext
options :address, :type => :fulltext
end
是否尝试将
接受\u嵌套的\u属性\u:translations
添加到您的模型中?
search_scope :search do
attributes name: "translations.name", address: "translations.address"
options :name, :type => :fulltext
options :address, :type => :fulltext
end