Last active
September 25, 2019 05:09
-
-
Save dyanagi/0259af6f4ed5da4b76f0ad18581f725e to your computer and use it in GitHub Desktop.
A Rake task file that populates example data for development in Ruby on Rails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/tasks/dev.rake | |
if Rails.env.development? | |
namespace :dev do | |
desc 'Drop, create, load schema, migrate, seed, and populate sample data' | |
task prepare: ['db:drop', 'db:create', 'db:schema:load', | |
'db:migrate', 'db:seed', :populate_sample_data] do | |
puts 'Ready to go!' | |
end | |
desc 'Populates the database with sample data' | |
task populate_sample_data: :environment do | |
user = User.new email: '[email protected]', password: 'password' | |
user.skip_confirmation! | |
user.save! | |
# Add more sample data | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment