开发者

Search in Rails using find

@user_post = Post.find(:all,:conditions开发者_运维问答 => ["content LIKE ?", "%#{params[:query]}%"])

This particular statement returning nil even though there exists a record in the database. Where could be the problem?

Please help me out.


Have you verified that the parameters are being passed in correctly? When a query isn't returning expected results it is almost always because the query you think you are executing isn't really the query that you are executing. Take a look at your log files to verify the that the query is correct.


have you tried running resulting query in mysql console? if you do have result then keep debugging, error is somewhere between controller action and rendered view. maybe you're loading result in before_filter which is not executed for your action?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜