/
seeds.rb
28 lines (24 loc) · 1.04 KB
/
seeds.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Seed add you the ability to populate your db.
# We provide you a basic shell for interaction with the end user.
# So try some code like below:
#
# name = shell.ask("What's your name?")
# shell.say name
#
email = shell.ask "Which email do you want use for loggin into admin?"
password = shell.ask "Tell me the password to use:"
shell.say ""
account = Account.create(:email => email, :name => "Foo", :surname => "Bar", :password => password, :password_confirmation => password, :role => "admin")
if account.valid?
shell.say "================================================================="
shell.say "Account has been successfully created, now you can login with:"
shell.say "================================================================="
shell.say " email: #{email}"
shell.say " password: #{password}"
shell.say "================================================================="
else
shell.say "Sorry but some thing went worng!"
shell.say ""
account.errors.full_messages.each { |m| shell.say " - #{m}" }
end
shell.say ""