Overriding Rails 3 database configuration depending upon platform
https://gist.github.com/1418782
configuration_extensions.rb
# lib/extenstions/configuration_extentions.rb
module Rails
class Application
class Configuration
def database_configuration
require 'erb'
case RUBY_PLATFORM.downcase
when /darwin/
YAML::load(ERB.new(IO.read('config/database_mac.yml')).result)
when /mswin/, /ming/
YAML::load(ERB.new(IO.read('config/database_win.yml')).result)
when /java/
YAML::load(ERB.new(IO.read('config/database_java.yml')).result)
else
YAML::load(ERB.new(IO.read(paths["config/database"].first)).result)
end
end
end
end
end
environment.rb
# config/environment.rb
require 'extensions/configuration_extensions'
# Initialize the rails application
Written by Edward J. Stembler
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails 3
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#