Hi there,
I'm having difficulty inserting an array into a postgres db. I'm scoured
the internet for help, tried many solutions, but am still having trouble.
I'm using Rails 4.1.6
I have a pg database with the following migration:
add_column :dock_slip, :shore_power, :text, array:true, default: []
which appears in my schema like:
t.text "shore_power", default: [],
array: true
I am using a bootstrap multiselect from a form to produce array data. I get
the param data in the format:
"shore_power"=>["30 amp", "50 amp", "100 amp"]
In my model, I'm updating a bunch of attributes, including the above
(missing some stuff....but like this). And saving of course:
slip.attributes = {shore_power: slip_data['shore_power']}
slip.save
This produces the following SQL statement - which seems incorrect to me.
The data appears to be in the correct array format originally though:
SQL (0.5ms) UPDATE "dock_slips" SET "shore_power" = $1 WHERE "dock_slips"
."id" = 1 [["shore_power", "---\n- 30 amp\n- 50 amp\n- 100 amp\n"]]
Any input would be much appreciated. Thanks in advance.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/7eae91b7-f4ce-4db6-83ca-20f9fa215d61%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.