If you are beginner in Ruby on Rails you maybe think If there is some easy way to populate you database. The answer is: Yes! Using Rails you get a lot of productive and keep your focus on the application design. As you know, the Rails uses the design paradigm convention over configuration, which seeks to decrease the number of decision that the developers need to make. With this in mind, if you look at your rails application schema, we can see the file seeds.rb .
At this file, you may put your data which you want to populate your database.
User.create(:name=> "Harold Marcelo", :age=>30) User.create(:name => "Jefferson", :age=>28) User.create(:name=>"Little Boy", :age=>20) Place.create(:name=> "School") Place.create(:name=> "Church") rake db:seed #Load the seed data from db/seeds.rb #OR rake db:reset Drops and recreates the database from db/schema.rb for the current environment and loads the seeds.
Now, you can create your administrators, for example. I need to migrate an application and I’ve created a file which contains all the old database,I think this is not the purpose of the seed, but you can use it for things like this too.