我在bundlen install之后重新启动服务器
我的环境
ruby 2.1.5,rails 4.0.13,ransack 1.6.3
使用控制台
的结果User.first
=> #<User id: 1, email: "email@mail.com">
User.ransack({"email"=>"email@mail.com"}).result.to_sql
=> "SELECT \"users\".* FROM \"users\""
User.search({"email"=>"email@mail.com"}).result.to_sql
=> "SELECT \"users\".* FROM \"users\""
User.where({"email"=>"email@mail.com"}).to_sql
=> "SELECT \"users\".* FROM \"users\" WHERE \"users\".\"email\" = 'email@mail.com'"
答案 0 :(得分:1)
User.ransack(email_eq: "email@mail.com").result
阅读eq (equals)文档。