I am trying to add a multiple image uploader with Carrierwave following the documentation to my app.
Normally my schema.rb looks like this
ActiveRecord::Schema.define(version: 20160814232416) do
create_table "progresses", force: :cascade do |t|
t.string "title"
t.string "date"
t.text "content"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
end
And when I run :
rails g migration add_images_to_progresses images:json
and
rake db:migrate
My schema change and display that weird thing.... Is it a problem with Sqlite3 or Pg? What should I do ?
ActiveRecord::Schema.define(version: 20160815005123) do
# Could not dump table "progresses" because of following NoMethodError
#undefined method `[]' for nil:NilClass
end
I tried using the same code for both SQLite and PostgreSql. In SQLite there is no datatype "JSON" available, and so it throws an error. When I tried the same in PostgreSQL, it worked.
If you want to use the SQLite then you will have to generate a string from your JSON and then save that string in your database as a regular string.
I prefer to use PostgreSQL, which supports JSON datatype.