/config/environment.rb

https://github.com/ruelbargo/ThoughtStream · Ruby · 87 lines · 51 code · 17 blank · 19 comment · 3 complexity · 0e1f6bee57c80c1f579755a13f6b5b42 MD5 · raw file

  1. # Load the Rails framework and configure your application.
  2. # You can include your own configuration at the end of this file.
  3. #
  4. # Be sure to restart your webserver when you modify this file.
  5. # The path to the root directory of your application.
  6. RAILS_ROOT = File.join(File.dirname(__FILE__), '..')
  7. # The environment your application is currently running. Don't set
  8. # this here; put it in your webserver's configuration as the RAILS_ENV
  9. # environment variable instead.
  10. #
  11. # See config/environments/*.rb for environment-specific configuration.
  12. RAILS_ENV = ENV['RAILS_ENV'] || 'development'
  13. # Load the Rails framework. Mock classes for testing come first.
  14. ADDITIONAL_LOAD_PATHS = ["#{RAILS_ROOT}/test/mocks/#{RAILS_ENV}"]
  15. # Then model subdirectories.
  16. ADDITIONAL_LOAD_PATHS.concat(Dir["#{RAILS_ROOT}/app/models/[_a-z]*"])
  17. ADDITIONAL_LOAD_PATHS.concat(Dir["#{RAILS_ROOT}/components/[_a-z]*"])
  18. # Followed by the standard includes.
  19. ADDITIONAL_LOAD_PATHS.concat %w(
  20. app
  21. app/models
  22. app/controllers
  23. app/helpers
  24. app/apis
  25. components
  26. config
  27. lib
  28. vendor
  29. vendor/rails/railties
  30. vendor/rails/railties/lib
  31. vendor/rails/actionpack/lib
  32. vendor/rails/activesupport/lib
  33. vendor/rails/activerecord/lib
  34. vendor/rails/actionmailer/lib
  35. vendor/rails/actionwebservice/lib
  36. ).map { |dir| "#{RAILS_ROOT}/#{dir}" }.select { |dir| File.directory?(dir) }
  37. # Prepend to $LOAD_PATH
  38. ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) }
  39. # Require Rails libraries.
  40. require 'rubygems' unless File.directory?("#{RAILS_ROOT}/vendor/rails")
  41. require 'active_support'
  42. require 'active_record'
  43. require 'action_controller'
  44. require 'action_mailer'
  45. require 'action_web_service'
  46. # Environment-specific configuration.
  47. require_dependency "environments/#{RAILS_ENV}"
  48. ActiveRecord::Base.configurations = File.open("#{RAILS_ROOT}/config/database.yml") { |f| YAML::load(f) }
  49. ActiveRecord::Base.establish_connection
  50. # Configure defaults if the included environment did not.
  51. begin
  52. RAILS_DEFAULT_LOGGER = Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}.log")
  53. RAILS_DEFAULT_LOGGER.level = (RAILS_ENV == 'production' ? Logger::INFO : Logger::DEBUG)
  54. rescue StandardError
  55. RAILS_DEFAULT_LOGGER = Logger.new(STDERR)
  56. RAILS_DEFAULT_LOGGER.level = Logger::WARN
  57. RAILS_DEFAULT_LOGGER.warn(
  58. "Rails Error: Unable to access log file. Please ensure that log/#{RAILS_ENV}.log exists and is chmod 0666. " +
  59. "The log level has been raised to WARN and the output directed to STDERR until the problem is fixed."
  60. )
  61. end
  62. [ActiveRecord, ActionController, ActionMailer].each { |mod| mod::Base.logger ||= RAILS_DEFAULT_LOGGER }
  63. [ActionController, ActionMailer].each { |mod| mod::Base.template_root ||= "#{RAILS_ROOT}/app/views/" }
  64. # Set up routes.
  65. ActionController::Routing::Routes.reload
  66. Controllers = Dependencies::LoadingModule.root(
  67. File.join(RAILS_ROOT, 'app', 'controllers'),
  68. File.join(RAILS_ROOT, 'components')
  69. )
  70. # Include your app's configuration here: