Created
February 19, 2012 17:10
-
-
Save hernamesbarbara/1864672 to your computer and use it in GitHub Desktop.
Create Admin User in Ruby on Rails Application using rake db:seed
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
#db/seeds.rb | |
# Run 'rake db:seed' from terminal to create an Admin User in your database | |
#Seed DB with at least 1 Admin User | |
admin=User.new({ name: "Admin User", email: '[email protected]', | |
password: 'password', password_confirmation: 'password'}) | |
admin.toggle!(:admin) | |
if admin.valid? | |
admin.save() | |
elsif admin.errors.any? | |
admin.errors.full_messages.each do |msg| | |
puts msg | |
end | |
else | |
puts "****NOT VALID****" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment