Fi3n1k
Fi3n1k

Reputation: 891

Migration into RAILS 4.2

I migrate from Rails 3.x to Rails 4.2

I have the following code:

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,
]

and when I run the tests I get the following deprication:

DEPRECATION WARNING: Relation#all is deprecated. If you want to eager-load a relation, you can call #load (e.g. Post.where(published: true).load). If you want to get an array of records from a relation, an> you can call #to_a (e.g. Post.where(published: true).to_a). (called from similar_flagged_orders at /Users/fisnik/code/myr-admin/app/models/order.rb:173)

Any suggestions please ?

Upvotes: 0

Views: 35

Answers (1)

Andrey Deineko
Andrey Deineko

Reputation: 52347

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
)

Upgrade from 3.x straight to 4.2 is insane and inevitably you will struggle a lot to make things work.

Do it gradually.

First upgrade to 3.2, then to 4.0, and only here you have 2 options - 4.1 and 4.2.

Also gradually upgrade your testing framework.

Upvotes: 1

Related Questions