2
我必須搜索書籍,用戶通過作者的書籍需要能夠搜索他們的書籍而不顯示其他用戶的書籍。使用Elasticsearch和Searchkick on Rails通過關聯查找用戶項目?
書籍模型
has_many :authors
has_many :users, through: :authors
我試圖描述here進行搜索,但沒有奏效。
@Books = Book.search "*", where: { user_id: current_user.id}
我認爲它沒有工作,因爲books
模型沒有user_id