我从Rails 3.x迁移到Rails 4.2
我有以下代码:
Order.all :conditions => ["flagged = ? AND orders_id != ? AND (
delivery_name = ? OR
delivery_telephone = ? OR
email = ? OR
((delivery_address IS NOT NULL AND delivery_address != '') AND delivery_address = ?) OR
(remote_ip IS NOT NULL AND remote_ip = ?)
)",
true,
self.orders_id,
self.delivery_name,
self.delivery_telephone,
self.email,
self.delivery_address,
self.remote_ip,
]
当我运行测试时,我得到以下的修复:
DEPRECATION WARNING:不推荐使用Relation#all。如果你想 急切加载关系,你可以调用#load(例如
Post.where(published: true).load
)。如果要从关系中获取记录数组, 一个>你可以拨打#to_a(例如Post.where(published: true).to_a
)。 (称为 来自similar_flagged_orders at /Users/fisnik/code/myr-admin/app/models/order.rb:173)
有什么建议吗?
答案 0 :(得分:1)
Order.where("flagged = ? AND orders_id != ? AND (
delivery_name = ? OR
delivery_telephone = ? OR
email = ? OR
((delivery_address IS NOT NULL AND delivery_address != '') AND delivery_address = ?) OR
(remote_ip IS NOT NULL AND remote_ip = ?)
)",
true,
orders_id,
delivery_name,
delivery_telephone,
email,
delivery_address,
remote_ip
)
从3.x直接升级到4.2是疯狂的,你不可避免地要努力使事情发挥作用。
首先升级到3.2,然后升级到4.0,只有这里有2个选项 - 4.1和4.2。
逐步升级您的测试框架。