Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move session and session_store onto ActionDispatch and add deprecatio…

…n warnings
  • Loading branch information...
commit 17769696279810c6c24a10b0d47f9b712205f0ce 1 parent c0c1599
Carlhuda authored
View
6 actionpack/lib/action_controller/metal/compatibility.rb
@@ -158,6 +158,12 @@ def trusted_proxies
Rails.application.config.action_dispatch.ip_spoofing_check = value
end
+ def session=(value)
+ ActiveSupport::Deprecation.warn "ActionController::Base.session= is deprecated. " <<
+ "Please configure it on your application with config.action_dispatch.session=", caller
+ Rails.application.config.action_dispatch.session = value.delete(:disabled) ? nil : value
+ end
+
def rescue_action(env)
raise env["action_dispatch.rescue.exception"]
end
View
5 actionpack/lib/action_controller/metal/session_management.rb
@@ -27,11 +27,6 @@ def session_store
SessionManagement.session_store_for(config.session_store)
end
- def session=(options = {})
- self.session_store = nil if options.delete(:disabled)
- session_options.merge!(options)
- end
-
def session(*args)
ActiveSupport::Deprecation.warn(
"Disabling sessions for a single controller has been deprecated. " +
View
50 actionpack/lib/action_controller/railtie.rb
@@ -3,6 +3,7 @@
require "action_view/railtie"
require "active_support/core_ext/class/subclasses"
require "active_support/deprecation/proxy_wrappers"
+require "active_support/deprecation"
module ActionController
class Railtie < Rails::Railtie
@@ -11,33 +12,48 @@ class Railtie < Rails::Railtie
require "action_controller/railties/log_subscriber"
require "action_controller/railties/url_helpers"
- log_subscriber ActionController::Railties::LogSubscriber.new
+ ad = config.action_dispatch
+ config.action_controller.singleton_class.send(:define_method, :session) do
+ ActiveSupport::Deprecation.warn "config.action_controller.session has been " \
+ "renamed to config.action_dispatch.session.", caller
+ ad.session
+ end
- config.action_controller.session_store = :cookie_store
- config.action_controller.session_options = {}
+ config.action_controller.singleton_class.send(:define_method, :session=) do |val|
+ ActiveSupport::Deprecation.warn "config.action_controller.session has been " \
+ "renamed to config.action_dispatch.session.", caller
+ ad.session = val
+ end
- initializer "action_controller.logger" do
- ActionController::Base.logger ||= Rails.logger
+ config.action_controller.singleton_class.send(:define_method, :session_store) do
+ ActiveSupport::Deprecation.warn "config.action_controller.session_store has been " \
+ "renamed to config.action_dispatch.session_store.", caller
+ ad.session_store
end
- # assets_dir = defined?(Rails.public_path) ? Rails.public_path : "public"
- # ActionView::DEFAULT_CONFIG = {
- # :assets_dir => assets_dir,
- # :javascripts_dir => "#{assets_dir}/javascripts",
- # :stylesheets_dir => "#{assets_dir}/stylesheets",
- # }
+ config.action_controller.singleton_class.send(:define_method, :session_store=) do |val|
+ ActiveSupport::Deprecation.warn "config.action_controller.session_store has been " \
+ "renamed to config.action_dispatch.session_store.", caller
+ ad.session_store = val
+ end
+ log_subscriber ActionController::Railties::LogSubscriber.new
+
+ initializer "action_controller.logger" do
+ ActionController::Base.logger ||= Rails.logger
+ end
initializer "action_controller.set_configs" do |app|
paths = app.config.paths
ac = app.config.action_controller
- ac.assets_dir = paths.public
- ac.javascripts_dir = paths.public.javascripts
- ac.stylesheets_dir = paths.public.stylesheets
+ ac.assets_dir = paths.public.to_a.first
+ ac.javascripts_dir = paths.public.javascripts.to_a.first
+ ac.stylesheets_dir = paths.public.stylesheets.to_a.first
- app.config.action_controller.each do |k,v|
- ActionController::Base.send "#{k}=", v
- end
+ ActionController::Base.config.replace(ac)
+ # app.config.action_controller.each do |k,v|
+ # ActionController::Base.send "#{k}=", v
+ # end
end
initializer "action_controller.initialize_framework_caches" do
View
2  actionpack/lib/action_dispatch/railtie.rb
@@ -7,6 +7,8 @@ class Railtie < Rails::Railtie
config.action_dispatch.x_sendfile_header = "X-Sendfile"
config.action_dispatch.ip_spoofing_check = true
+ config.action_dispatch.session = {}
+ config.action_dispatch.session_store = :cookie_store
# Prepare dispatcher callbacks and run 'prepare' callbacks
initializer "action_dispatch.prepare_dispatcher" do |app|
View
4 railties/lib/rails/railtie/configuration.rb
@@ -86,8 +86,8 @@ def default_middleware
middleware.use('::Rack::Sendfile', lambda { action_dispatch.x_sendfile_header })
middleware.use('::ActionDispatch::Callbacks', lambda { !cache_classes })
middleware.use('::ActionDispatch::Cookies')
- middleware.use(lambda { ActionController::SessionManagement.session_store_for(action_controller.session_store) }, lambda { action_controller.session })
- middleware.use('::ActionDispatch::Flash', :if => lambda { action_controller.session_store })
+ middleware.use(lambda { ActionController::SessionManagement.session_store_for(action_dispatch.session_store) }, lambda { action_dispatch.session })
+ middleware.use('::ActionDispatch::Flash', :if => lambda { action_dispatch.session_store })
middleware.use(lambda { metal_loader.build_middleware(metals) }, :if => lambda { metal_loader.metals.any? })
middleware.use('ActionDispatch::ParamsParser')
middleware.use('::Rack::MethodOverride')
Please sign in to comment.
Something went wrong with that request. Please try again.