Last Updated: February 25, 2016
·
1.135K
· prathamesh-sonpatki

Load seed data from Rails app

To load seed data from Rails app,

Rails.application.load_seed

I had the usecase, where some of the constants defined were using some fixed data from database.

rake db:seed was also failing because it was trying to define those constants first.

So i had to seed data from the Rails app itself. So i put above code in one of my initializers based on a condition.