Reputation: 6647
I'm trying to update some min and max fields so that is one is left empty then the value is copied form the other. So far I have:
Item.update_all({:min = :max}, {:min => nil, :max !=> nil})
Since both fields could be nil
I have whether they are but the !=>
isn't correct. How would I go about testing for not equal to using this style of condition?
Upvotes: 1
Views: 1180
Reputation: 15808
This is not valid ruby syntax for hashes.
Try:
Item.update_all("min = max", "min IS NULL AND max IS NOT NULL")
Or alternatively:
Item.where("min IS NULL AND max IS NOT NULL").update_all("min = max")
Upvotes: 4