Mysql syntaxerror while trying multiple image upload in rails using carrierwave gem -


i'm following carrierwave documentation here upload multiple images listing model. when, used command

rails g migration add_images_to_listings images:json 

migration gets created -

class addimagestolistings < activerecord::migration   def change     add_column :listings, :images, :json   end end 

but running rake db:migrate throws mysql syntax error

     mysql2::error: have error in sql syntax; check manual corresponds mysql server version right syntax use near 'json'      @ line 1: alter table `listings` add `images` json/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:299:in `query' 

i suspect because json data type not supported mysql. there workaround?

as can see here https://dev.mysql.com/doc/refman/5.7/en/json.html

json datatype available on mysql 5.7.8 or above.

and here https://github.com/rails/rails/pull/21110

mysql json type added on rails 5.

so if setup below these configurations, cant use json mysql.

but can workaround problem using :text type on migration:

class addimagestolistings < activerecord::migration   def change     add_column :listings, :images, :text   end end 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -