我有这个
代码:
Article.find([1,2,3])
但只有数据库中存在1和2记录.我得到这个例外:
"ActiveRecord::RecordNotFound (Couldn't find all Offers with IDs (1,3) (found 2 results,but was looking for 3))"
有没有办法只得到现有的记录,而不是异常?
Article.find_all_by_id([1,3])是要走的路!
原文链接:https://www.f2er.com/ruby/272327.html