看起来我的引号有问题?
我的命名范围:
named_scope :find_by_name, lambda {|name| {:conditions => ["first_name LIKE '%?%' or last_name LIKE '%?%'", name.split(' ').first, name.split(' ').last]}}
这是我进行搜索的方式:
find_by_name("#{search}")
这是生成的 SQL 和错误:
ActionView::Template::Error (Mysql::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'foo'%' or last_name LIKE '%'foo'%')' at line 1: SELECT COUNT(*) FROM `users` WHERE (first_name LIKE '%'foo'%' or last_name LIKE '%'foo'%')):