Ruby on rails database: can you create records in your code -


i wan create admin user application. want have admin created @ same time when application created. want record admin in database @ beginning. possible initialize administrator before creating application, when put application on heroku , goes production mode, admin there password , username specified in code?

yes can done, using seeds.rb. can add initial datas loaded in application after first deployment.

your can write first admin created in seeds.rb

db/seeds.rb 

in local can run rake db:seed (to populate initial datas)

if using default postgresql (of heroku), can run as,

heroku pg:reset heroku run rake db:seed 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -