Ive seen some other questions, but none of them seem to help.
Basically here is my controller:
def append
y = Post.find(params[:id])
y.tags_will_change!
y.tags.push(params[:x].to_i)
y.save!
Post.find(params[:id]).tags
redirect_to root_path
end
and I get this error, PG::InvalidTextRepresentation at /posts/22/append ERROR: array value must start with "{" or dimension information.
Request parameters
{"x"=>"9", "controller"=>"posts", "action"=>"append", "id"=>"22"}
Note: tags is defined as an integer type array => true (i.e. an integer array)
Post model migration:
class AddTagsToPosts < ActiveRecord::Migration
def change
add_column :posts, :tags, :integer, array: true, default: []
end
end
from schema.rb :
create_table "posts", force: :cascade do |t|
t.integer "tags", default: [], array: true
Ive checked the other answers on here, but none seemed to help.