where 查詢條件 使用like statement
2012-01-03 17:22:25 +0800 由 royc
在 Ruby on Rails 節點 中發起
最後由 royc 於2012-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 條回應
hechian
1樓, 於2012-01-03 18:17:03 +0800回應
把要用LIKE的獨立出來,再串一個where
Post.where({:author => "royc"}).where(["title LIKE ?", "statement"])
xdite
2樓, 於2012-01-03 18:17:58 +0800回應
http://github.com/ernie/meta_search 這個 gem 應該可以滿足你的需求
royc
3樓, 於2012-01-04 09:35:49 +0800回應
ok,解決了,感謝兩位