initially populate data in rails if database is empty from application -


i have created database migration, , migrated data both on development , production servers. populate database application, if empty , avoid rake db:seed , other similar methods. know done through rake db:seed, since application deployed not pollute deploy.rb capistrano, or manually on both development , production.

is there hook on database open or initialization of active record can like

if !pages.first   pages.populate end 

i aware of recommended methods populate database, still prefer app.

thanks

as eluded to, not best idea in world, maybe try using on of these approaches:

  1. an initializer called each time rails environment loaded.
  2. something in config.after_initialize block. see http://guides.rubyonrails.org/configuring.html

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -