Skip to content

Commit

Permalink
Merge pull request #5 from brunoluigi/patch-1
Browse files Browse the repository at this point in the history
Fixed setting environment by passing argument "-e"
  • Loading branch information
pauldix committed Mar 3, 2012
2 parents 00da625 + 5ed8ce7 commit d700116
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion chapter_01/service.rb
Expand Up @@ -6,7 +6,8 @@
require "#{File.dirname(__FILE__)}/models/user"

# setting up our environment
env_arg = ARGV.index("-e")
env_index = ARGV.index("-e")
env_arg = ARGV[env_index + 1] if env_index
env = env_arg || ENV["SINATRA_ENV"] || "development"
databases = YAML.load_file("config/database.yml")
ActiveRecord::Base.establish_connection(databases[env])
Expand Down

0 comments on commit d700116

Please sign in to comment.