我正在使用get方法发送数据,并且需要将其放入一个int数组中以便在查找中使用。 以下是我的代码:
@found = Array.new
params['candidate'].each do |c|
@found << c.to_i
end
我的网址看起来像这样
http://localhost:3000/export/candidate?candidate[]=3&candidate[]=4&commit=Export
如果有所不同,我正在使用它来查找。
@candidate = Candidate.find(:all, :conditions => ["candidates.id IN ?", @found])
但目前它并没有将其放入真正的数组中,因为我遇到了这个错误
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 '4)' at line 1: SELECT * FROM `candidates` WHERE (candidates.id IN 4,2)
数组周围缺少括号
谢谢,早上好!
Alex