Permalink
Browse files

Merge pull request #5 from brunoluigi/patch-1

Fixed setting environment by passing argument "-e"
  • Loading branch information...
2 parents 00da625 + 5ed8ce7 commit d70011651d786c8284d606d3bafef2c46a143b2c @pauldix committed Mar 3, 2012
Showing with 2 additions and 1 deletion.
  1. +2 −1 chapter_01/service.rb
View
@@ -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])

0 comments on commit d700116

Please sign in to comment.