0
https://github.com/ankane/searchkickを使用して、Users
とSkills
の両方を検索し、検索されたスキルを持つユーザーを返すにはどうすればよいですか。最も関連性の高い結果には、User
のどれが多く含まれているかが反映されるはずです。searchkick検索HABTM
私のモデルは次のようになります。私は次のことを試してみましたが、何も結果が返されない
class User < ApplicationRecord
searchkick
has_many :user_skills
has_many :skills, through: :user_skills
end
class Skill < ApplicationRecord
searchkick
has_many :user_skills
has_many :users, through: :user_skills
end
class UserSkill < ApplicationRecord
searchkick
belongs_to :user
belongs_to :skill
end
:
@search = User.search "*", where: {
skill_ids: {all: [1, 3]}
}
@fbelanger。私は、https://github.com/ankane/searchkickが私のニーズに合わせて複雑になることを発見しました。だから私は代わりにhttps://github.com/activerecord-hackery/ransackに切り替えました –