【发布时间】:2015-08-06 22:51:51
【问题描述】:
我有一个 id 数组,我想使用活动记录查询从数据库中找到它们各自的记录。例如:ids = [2, 3, 1]
现在,我要查找特定模型的所有记录,其 id 是数组中的一个,在较低版本的 rails 中,我想我可以执行以下操作:
Model.find_all_by_id([2, 3, 1])
但是根据this post,
These methods were deprecated on 4.0 and removed at 4.1. If you want to
keep sing then you need to include this gem
https://github.com/rails/activerecord-deprecated_finders
我的问题是,我没有办法在 rails4.2 中做到这一点而不必包含一个 gem?
谢谢。
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-4 activerecord