How to set default value for new objects only, in Rails Migration? -


i know how set default value column in rails, find myself in situation this, example :
boolean field named 'settled', default value false
new objects not settled until so, need old objects settled

what making rake task toggle old objects, there way in migration not script, set value default old objects not future schema

you can in migration:

add_column :users, :is_banned, :bool user.update_all(is_banned: false) 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -