fix double requiring of application.rb

This happens when script/rails is executed via a symlinked canvas
directory

Change-Id: I64fc408244ead13c3c78580c3b3e72102445df34
Reviewed-on: https://gerrit.instructure.com/40740
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
Brian Palmer 2014-09-08 15:44:25 -06:00 committed by Cody Cutrer
parent c689ac0add
commit 7b2523fca1
2 changed files with 11 additions and 7 deletions

View File

@ -87,13 +87,12 @@ module CanvasRails
initializer("extend_middleware_stack", after: "load_config_initializers") do |app|
app.config.middleware.insert_before(config.session_store, 'LoadAccount')
app.config.middleware.insert_before(config.session_store, 'SessionsTimeout')
app.config.middleware.swap('ActionDispatch::RequestId', "RequestContextGenerator")
app.config.middleware.insert_before('ActionDispatch::ParamsParser', 'StatsTiming')
app.config.middleware.insert_before('ActionDispatch::ParamsParser', 'Canvas::RequestThrottle')
app.config.middleware.insert_before('Rack::MethodOverride', 'PreventNonMultipartParse')
end
config.middleware.swap('ActionDispatch::RequestId', "RequestContextGenerator")
config.middleware.insert_before('ActionDispatch::ParamsParser', 'StatsTiming')
config.middleware.insert_before('ActionDispatch::ParamsParser', 'Canvas::RequestThrottle')
config.middleware.insert_before('Rack::MethodOverride', 'PreventNonMultipartParse')
config.to_prepare do
require_dependency 'canvas/plugins/default_plugins'
ActiveSupport::JSON::Encoding.escape_html_entities_in_json = true

View File

@ -1,6 +1,11 @@
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
# added by instructure:
# resolve any symlinks in the file path, to avoid double-require issues
require 'pathname'
expanded_path = Pathname.new(__FILE__).realpath
APP_PATH = File.expand_path('../../config/application', expanded_path)
require File.expand_path('../../config/boot', expanded_path)
require 'rails/commands'