I am updating from Rails 3 to Rails 4.2, and when I run my application's test suite, I get the following error:
Failure/Error: get 'edit', id: @shops[3].id
NoMethodError:
undefined method `map!' for #<Shop::ActiveRecord_Relation:0x007ff1d69b4f40>
The code in the controller is:
existing_shops.map! { |obj| [["##{obj[:shop_id]} #{obj[:name]},
#{obj[:phone]}, #{obj[:address]}, #{obj[:city]}, #{obj[:state]}, #{obj[:zipcode]} "]]}
I am using Rails 4.2.4 and RSpec 3.3.0.
Relation no longer has mutator methods like #map! and #delete_if. Convert to an Array by calling #to_a before using these methods.
existing_shops.to_a.map! { ... }
— A Guide for Upgrading Ruby on Rails
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With