I have created database migration, and migrated data both on development and production servers. I would like to populate database from the application, if it is empty and avoid rake db:seed and other similar methods. I know that it could be done through rake db:seed, but since application is already deployed I would not like to pollute deploy.rb for capistrano, or do it manually on both development and production.
Is there any hook on database open or initialization of Active Record where I can do something like
if !Pages.first
Pages.populate
end
I am aware of all recommended methods to populate database, but I would still prefer to do it from app.
Thanks
As you eluded to, this is not the best idea in the world, but maybe you could try using on of these approaches:
config.after_initialize
block. See http://guides.rubyonrails.org/configuring.html