mardi 16 octobre 2018

Add Default Value to datatype Array in Rails migration

I was trying to create a field which is datatype of Array through migration and it did got updated in schema.rb file.

However my main goal was to give fixed value to this field (i-e Array) which is not going to change in future. Kinda static value.

I applied this method to create a field.

rails generate migration Store_detailsToAdmin store_details:string

Admin.rb file.

serialize :store_details, Array

rake db:migrate

Can anyone help me out to have default and fixed value to this column. Any help would really be appreciated. Just a heads up i'm very new to rails world. Apologize in advance.

Aucun commentaire:

Enregistrer un commentaire