[英]How to perform a search using pg search gem for a field that is assoicatied through another table?
我有一個名為user的表,我剛剛創建了一個標記系統,用戶可以在其中通過另一個表進行標記。 這種鐵路演員為其書籍和作者所做的方式相同。
現在我已經有了基於這種方式的搜索:
def self.text_search(query)
if query.present?
where("first_name @@ :q OR last_name @@ :q OR country @@ :q OR (first_name || ' ' || last_name) @@ :q", :q => query)
else
scoped
end
end
如果我在用戶表內沒有要搜索的字段,那么有人可以建議我加入搜索嗎? 我只是用pg_search弄不清楚語法
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.