activerecord-postgres-array icon indicating copy to clipboard operation
activerecord-postgres-array copied to clipboard

Incorrect extraneous quoting when trying to update/insert

Open avishai opened this issue 11 years ago • 4 comments

I've been using this gem for over a year, and I just ran bundle update and for some reason now it keeps raising unit_amenities must be an Array or have a valid array value (''{"balcony","dishwasher","hardwood floors","home office","tile floors"}'')

params[:unit_amenities] are submitted as follows:

"unit_amenities"=>["balcony",
 "dishwasher",
 "hardwood floors",
 "home office",
 "tile floors"],

In the Rails console, this is what I get:

1.9.3p429 :007 > a.unit_amenities
 => ["dishwasher", "balcony"] 
1.9.3p429 :008 > a.unit_amenities << "hardwood floors"
 => ["dishwasher", "balcony", "hardwood floors"] 
1.9.3p429 :009 > a.save
   (0.2ms)  BEGIN
   (0.9ms)  UPDATE "listings" SET "description" = 'Little Italy was once a lively home for the most of the Italian population in New York. state-of-the-art laundry facilities, [...]', "updated_at" = '2013-10-15 18:19:50.153309' WHERE "listings"."id" = 1032369
   (23.7ms)  COMMIT
 => true 
1.9.3p429 :010 > a.unit_amenities
 => ["dishwasher", "balcony"] # is appears that the updates are just completely dropped from the update, also.

avishai avatar Oct 15 '13 18:10 avishai

@tlconnor could this get merged?

joevandyk avatar Dec 17 '13 18:12 joevandyk

Because of this bug, the gem is worthless.

pokonski avatar Jan 29 '14 16:01 pokonski

You can downgrade to version 0.0.9, that should fix the bug. You can can safely stay at this version, since this gem is not maintained anymore. Alternatively, try a fork: https://github.com/tlconnor/activerecord-postgres-array/pull/38

leovandriel avatar Jan 29 '14 16:01 leovandriel

@leonardvandriel thanks. Just did that and 0.0.9 works fine :)

pokonski avatar Jan 29 '14 16:01 pokonski