I created a new migration for my Rails app on Heroku. It adds some Array columns like this:
t.string :timezone, array: true, default: [].to_yaml
t.string :locale, array: true, default: [].to_yaml
I get the following error when I try to migrate:
ActiveRecord::StatementInvalid: PG::InvalidTextRepresentation: ERROR: malformed array literal: "--- [] " DETAIL: Array value must start with "{" or dimension information. : CREATE TABLE "filters" ("id" serial primary key, "letter_id" integer, "gender" character varying, "timezone" character varying[] DEFAULT '--- [] ', "locale" character varying[] DEFAULT '--- []
Here is my model:
class Filter < ApplicationRecord
belongs_to :letter
serialize :timezone
serialize :locale
serialize :segment
validates_uniqueness_of :letter_id
end
Some people on Stackoverflow say removing serialize will do the trick but I need to store an array, not a string.
Any idea how I can solve this issue?