I am working with Rails4 with mysql. I have generated some migrations and mentioned the default value for some fields but after creating row the default value is storing as "NULL" in the database.
class CreateCities < ActiveRecord::Migration
def change
create_table :cities do |t|
t.string :name
t.integer :region_id
t.integer :country_id
t.integer :status, :default => 0
t.timestamps
end
end
end
I am not getting why it's not storing!!! In controller part also did like this,
def city_params
params.require(:city).permit!
end
Try this in you controller
def city_params
params.require(:city).permit(:name, :region_id, :country_id, :status)
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.