I have the array on my model and set up, and when I go to write the array onto my record it says COMMIT true, yet checking the field on that record immediately after returns an empty array.
Model:
class Feature < ActiveRecord::Base
serialize :content, Array
attr_accessible :content
end
Migration:
class AddContentToFeatures < ActiveRecord::Migration
def change
add_column :features, :content, :text, array: true, default: []
end
end
What I tried, along with various symbol and string syntaxes, is this:
> f=Feature.new
> f.content_will_change! #i feel like i shouldn't have to do this
> f.content = ['sadasd','asdasd']
> f.save!
BEGIN
COMMIT
=> true
> f.content
=> []
How do I persist the array on the model?
rake db:rollbackand then remove thearray: true, default: []and then migrate again. @peterkim 's suggestion makes sense to me.serializekludge with PostgreSQL is a bit nasty.postgresqltag. Either answer works, but the answer by @muistooshort is best one.