Last active
December 15, 2015 19:19
-
-
Save leemour/5310214 to your computer and use it in GitHub Desktop.
Depending on environment
This file contains hidden or 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
# Rails | |
case Rails.env | |
when "development" | |
... | |
when "production" | |
... | |
end | |
#Padrino | |
# 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 | |
# | |
case Padrino.env | |
when :development | |
email = shell.ask "Which email do you want use for logging into admin?" | |
password = shell.ask "Tell me the password to use:" | |
shell.say "" | |
when :production | |
email = "[email protected]" | |
password = "12345" | |
end | |
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 wrong!" | |
shell.say "" | |
account.errors.full_messages.each { |m| shell.say " - #{m}" } | |
end | |
shell.say "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment