x無法存取,你可能沒有權限或未登入。
78fc3b3e9041dd38e14ec62fcbca3bca

where 查詢條件 使用like statement

2012-01-03 17:22:25 +0800roycRuby on Rails 節點 中發起
最後由 royc2012-01-04 09:35:49 +0800回應 , 265次閱讀

因為敝人的搜尋條件是用hash去包的像這樣
sql_arg["name"]="key"
然後下達的方式會如這樣
test.where(sql_arg)

但是要做到把這樣的敘述改成Like ,似乎找不到方式
請問是否有方法可以讓hash 使用 Like的查詢方式??還是一定要改array的方式?

截至 2012-01-04 09:35:49 +0800,共收到 3 條回應
Ff7afae5b23125e25e18ad8c0404bd78
hechian 1樓, 於2012-01-03 18:17:03 +0800回應

把要用LIKE的獨立出來,再串一個where
Post.where({:author => "royc"}).where(["title LIKE ?", "statement"])

19e786a2a74377ff6e052d87fd8d1fa8
xdite 2樓, 於2012-01-03 18:17:58 +0800回應

http://github.com/ernie/meta_search 這個 gem 應該可以滿足你的需求

78fc3b3e9041dd38e14ec62fcbca3bca
royc 3樓, 於2012-01-04 09:35:49 +0800回應

ok,解決了,感謝兩位

需要 登入 後方可回應,如果你還沒有帳號按這裡 註冊