actionpack 3.0.0.beta → 3.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of actionpack might be problematic. Click here for more details.
- data/CHANGELOG +291 -260
- data/lib/abstract_controller.rb +5 -2
- data/lib/abstract_controller/assigns.rb +21 -0
- data/lib/abstract_controller/base.rb +13 -5
- data/lib/abstract_controller/collector.rb +2 -0
- data/lib/abstract_controller/helpers.rb +4 -14
- data/lib/abstract_controller/layouts.rb +50 -99
- data/lib/abstract_controller/logger.rb +2 -2
- data/lib/abstract_controller/rendering.rb +105 -173
- data/lib/abstract_controller/view_paths.rb +69 -0
- data/lib/action_controller.rb +1 -2
- data/lib/action_controller/base.rb +10 -32
- data/lib/action_controller/caching.rb +19 -18
- data/lib/action_controller/caching/actions.rb +17 -11
- data/lib/action_controller/caching/fragments.rb +5 -17
- data/lib/action_controller/caching/pages.rb +24 -24
- data/lib/action_controller/caching/sweeping.rb +1 -3
- data/lib/action_controller/deprecated.rb +0 -2
- data/lib/action_controller/deprecated/base.rb +143 -0
- data/lib/action_controller/metal.rb +29 -26
- data/lib/action_controller/metal/compatibility.rb +18 -87
- data/lib/action_controller/metal/cookies.rb +0 -1
- data/lib/action_controller/metal/head.rb +1 -0
- data/lib/action_controller/metal/helpers.rb +2 -2
- data/lib/action_controller/metal/hide_actions.rb +4 -6
- data/lib/action_controller/metal/http_authentication.rb +18 -33
- data/lib/action_controller/metal/implicit_render.rb +21 -0
- data/lib/action_controller/metal/instrumentation.rb +1 -1
- data/lib/action_controller/metal/mime_responds.rb +2 -1
- data/lib/action_controller/metal/rack_delegation.rb +3 -8
- data/lib/action_controller/metal/redirecting.rb +2 -1
- data/lib/action_controller/metal/renderers.rb +4 -2
- data/lib/action_controller/metal/rendering.rb +31 -44
- data/lib/action_controller/metal/request_forgery_protection.rb +41 -4
- data/lib/action_controller/metal/responder.rb +2 -0
- data/lib/action_controller/metal/session_management.rb +0 -36
- data/lib/action_controller/metal/streaming.rb +20 -47
- data/lib/action_controller/metal/testing.rb +0 -1
- data/lib/action_controller/metal/url_for.rb +11 -148
- data/lib/action_controller/middleware.rb +2 -1
- data/lib/action_controller/polymorphic_routes.rb +1 -2
- data/lib/action_controller/railtie.rb +63 -10
- data/lib/action_controller/railties/{subscriber.rb → log_subscriber.rb} +5 -12
- data/lib/action_controller/railties/url_helpers.rb +14 -0
- data/lib/action_controller/record_identifier.rb +20 -1
- data/lib/action_controller/test_case.rb +123 -12
- data/lib/action_dispatch.rb +1 -0
- data/lib/action_dispatch/http/cache.rb +20 -3
- data/lib/action_dispatch/http/filter_parameters.rb +40 -25
- data/lib/action_dispatch/http/mime_negotiation.rb +6 -17
- data/lib/action_dispatch/http/mime_type.rb +2 -7
- data/lib/action_dispatch/http/request.rb +12 -33
- data/lib/action_dispatch/http/response.rb +35 -15
- data/lib/action_dispatch/http/upload.rb +2 -0
- data/lib/action_dispatch/http/url.rb +5 -32
- data/lib/action_dispatch/middleware/callbacks.rb +1 -1
- data/lib/action_dispatch/middleware/cookies.rb +4 -3
- data/lib/action_dispatch/middleware/params_parser.rb +4 -3
- data/lib/action_dispatch/middleware/remote_ip.rb +51 -0
- data/lib/action_dispatch/middleware/session/abstract_store.rb +1 -0
- data/lib/action_dispatch/middleware/session/cookie_store.rb +6 -8
- data/lib/action_dispatch/middleware/show_exceptions.rb +0 -14
- data/lib/action_dispatch/middleware/stack.rb +6 -2
- data/lib/action_dispatch/railtie.rb +3 -1
- data/lib/action_dispatch/routing.rb +2 -0
- data/lib/action_dispatch/routing/deprecated_mapper.rb +35 -7
- data/lib/action_dispatch/routing/mapper.rb +134 -48
- data/lib/action_dispatch/routing/route.rb +2 -2
- data/lib/action_dispatch/routing/route_set.rb +217 -158
- data/lib/action_dispatch/routing/url_for.rb +139 -0
- data/lib/action_dispatch/testing/assertions/response.rb +14 -61
- data/lib/action_dispatch/testing/assertions/routing.rb +25 -14
- data/lib/action_dispatch/testing/integration.rb +32 -50
- data/lib/action_dispatch/testing/performance_test.rb +3 -1
- data/lib/action_dispatch/testing/test_process.rb +2 -0
- data/lib/action_dispatch/testing/test_request.rb +2 -0
- data/lib/action_pack/version.rb +4 -3
- data/lib/action_view.rb +11 -6
- data/lib/action_view/base.rb +33 -121
- data/lib/action_view/context.rb +0 -2
- data/lib/action_view/helpers.rb +26 -23
- data/lib/action_view/helpers/active_model_helper.rb +28 -18
- data/lib/action_view/helpers/asset_tag_helper.rb +109 -54
- data/lib/action_view/helpers/atom_feed_helper.rb +2 -2
- data/lib/action_view/helpers/cache_helper.rb +22 -1
- data/lib/action_view/helpers/capture_helper.rb +22 -22
- data/lib/action_view/helpers/date_helper.rb +6 -5
- data/lib/action_view/helpers/form_helper.rb +78 -63
- data/lib/action_view/helpers/form_options_helper.rb +6 -4
- data/lib/action_view/helpers/form_tag_helper.rb +26 -15
- data/lib/action_view/helpers/javascript_helper.rb +90 -10
- data/lib/action_view/helpers/number_helper.rb +315 -118
- data/lib/action_view/helpers/prototype_helper.rb +19 -46
- data/lib/action_view/helpers/record_tag_helper.rb +4 -4
- data/lib/action_view/helpers/tag_helper.rb +7 -24
- data/lib/action_view/helpers/text_helper.rb +8 -7
- data/lib/action_view/helpers/translation_helper.rb +7 -5
- data/lib/action_view/helpers/url_helper.rb +19 -16
- data/lib/action_view/locale/en.yml +45 -6
- data/lib/action_view/lookup_context.rb +190 -0
- data/lib/action_view/paths.rb +22 -63
- data/lib/action_view/railtie.rb +14 -4
- data/lib/action_view/railties/{subscriber.rb → log_subscriber.rb} +1 -1
- data/lib/action_view/render/layouts.rb +73 -0
- data/lib/action_view/render/partials.rb +15 -41
- data/lib/action_view/render/rendering.rb +27 -78
- data/lib/action_view/template.rb +20 -24
- data/lib/action_view/template/error.rb +22 -2
- data/lib/action_view/template/handlers/erb.rb +33 -9
- data/lib/action_view/template/handlers/rjs.rb +1 -2
- data/lib/action_view/template/resolver.rb +46 -104
- data/lib/action_view/template/text.rb +5 -12
- data/lib/action_view/test_case.rb +14 -23
- metadata +83 -40
- data/lib/abstract_controller/compatibility.rb +0 -18
- data/lib/abstract_controller/localized_cache.rb +0 -49
- data/lib/action_controller/metal/configuration.rb +0 -28
- data/lib/action_controller/url_rewriter.rb +0 -76
@@ -0,0 +1,69 @@
|
|
1
|
+
module AbstractController
|
2
|
+
module ViewPaths
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
class_attribute :_view_paths
|
7
|
+
self._view_paths = ActionView::PathSet.new
|
8
|
+
end
|
9
|
+
|
10
|
+
delegate :find_template, :template_exists?, :view_paths, :formats, :formats=,
|
11
|
+
:locale, :locale=, :to => :lookup_context
|
12
|
+
|
13
|
+
# LookupContext is the object responsible to hold all information required to lookup
|
14
|
+
# templates, i.e. view paths and details. Check ActionView::LookupContext for more
|
15
|
+
# information.
|
16
|
+
def lookup_context
|
17
|
+
@lookup_context ||= ActionView::LookupContext.new(self.class._view_paths, details_for_lookup)
|
18
|
+
end
|
19
|
+
|
20
|
+
def details_for_lookup
|
21
|
+
{ }
|
22
|
+
end
|
23
|
+
|
24
|
+
def append_view_path(path)
|
25
|
+
lookup_context.view_paths.push(*path)
|
26
|
+
end
|
27
|
+
|
28
|
+
def prepend_view_path(path)
|
29
|
+
lookup_context.view_paths.unshift(*path)
|
30
|
+
end
|
31
|
+
|
32
|
+
module ClassMethods
|
33
|
+
# Append a path to the list of view paths for this controller.
|
34
|
+
#
|
35
|
+
# ==== Parameters
|
36
|
+
# path<String, ViewPath>:: If a String is provided, it gets converted into
|
37
|
+
# the default view path. You may also provide a custom view path
|
38
|
+
# (see ActionView::ViewPathSet for more information)
|
39
|
+
def append_view_path(path)
|
40
|
+
self.view_paths = view_paths.dup + Array(path)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Prepend a path to the list of view paths for this controller.
|
44
|
+
#
|
45
|
+
# ==== Parameters
|
46
|
+
# path<String, ViewPath>:: If a String is provided, it gets converted into
|
47
|
+
# the default view path. You may also provide a custom view path
|
48
|
+
# (see ActionView::ViewPathSet for more information)
|
49
|
+
def prepend_view_path(path)
|
50
|
+
self.view_paths = Array(path) + view_paths.dup
|
51
|
+
end
|
52
|
+
|
53
|
+
# A list of all of the default view paths for this controller.
|
54
|
+
def view_paths
|
55
|
+
_view_paths
|
56
|
+
end
|
57
|
+
|
58
|
+
# Set the view paths.
|
59
|
+
#
|
60
|
+
# ==== Parameters
|
61
|
+
# paths<ViewPathSet, Object>:: If a ViewPathSet is provided, use that;
|
62
|
+
# otherwise, process the parameter into a ViewPathSet.
|
63
|
+
def view_paths=(paths)
|
64
|
+
self._view_paths = paths.is_a?(ActionView::PathSet) ? paths : ActionView::Base.process_view_paths(paths)
|
65
|
+
self._view_paths.freeze
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/lib/action_controller.rb
CHANGED
@@ -13,13 +13,13 @@ module ActionController
|
|
13
13
|
autoload_under "metal" do
|
14
14
|
autoload :Compatibility
|
15
15
|
autoload :ConditionalGet
|
16
|
-
autoload :Configuration
|
17
16
|
autoload :Cookies
|
18
17
|
autoload :Flash
|
19
18
|
autoload :Head
|
20
19
|
autoload :Helpers
|
21
20
|
autoload :HideActions
|
22
21
|
autoload :HttpAuthentication
|
22
|
+
autoload :ImplicitRender
|
23
23
|
autoload :Instrumentation
|
24
24
|
autoload :MimeResponds
|
25
25
|
autoload :RackDelegation
|
@@ -46,7 +46,6 @@ module ActionController
|
|
46
46
|
|
47
47
|
eager_autoload do
|
48
48
|
autoload :RecordIdentifier
|
49
|
-
autoload :UrlRewriter
|
50
49
|
|
51
50
|
# TODO: Don't autoload exceptions, setup explicit
|
52
51
|
# requires for files that need them
|
@@ -2,7 +2,6 @@ module ActionController
|
|
2
2
|
class Base < Metal
|
3
3
|
abstract!
|
4
4
|
|
5
|
-
include AbstractController::Callbacks
|
6
5
|
include AbstractController::Layouts
|
7
6
|
include AbstractController::Translation
|
8
7
|
|
@@ -15,21 +14,23 @@ module ActionController
|
|
15
14
|
include ActionController::Renderers::All
|
16
15
|
include ActionController::ConditionalGet
|
17
16
|
include ActionController::RackDelegation
|
18
|
-
include ActionController::Configuration
|
19
17
|
|
20
18
|
# Legacy modules
|
21
19
|
include SessionManagement
|
22
20
|
include ActionController::Caching
|
23
21
|
include ActionController::MimeResponds
|
22
|
+
include ActionController::PolymorphicRoutes
|
24
23
|
|
25
24
|
# Rails 2.x compatibility
|
26
25
|
include ActionController::Compatibility
|
26
|
+
include ActionController::ImplicitRender
|
27
27
|
|
28
28
|
include ActionController::Cookies
|
29
29
|
include ActionController::Flash
|
30
30
|
include ActionController::Verification
|
31
31
|
include ActionController::RequestForgeryProtection
|
32
32
|
include ActionController::Streaming
|
33
|
+
include ActionController::RecordIdentifier
|
33
34
|
include ActionController::HttpAuthentication::Basic::ControllerMethods
|
34
35
|
include ActionController::HttpAuthentication::Digest::ControllerMethods
|
35
36
|
|
@@ -37,30 +38,11 @@ module ActionController
|
|
37
38
|
# all the methods properly.
|
38
39
|
include ActionController::Instrumentation
|
39
40
|
|
40
|
-
#
|
41
|
-
#
|
42
|
-
|
43
|
-
def send_action(*)
|
44
|
-
ret = super
|
45
|
-
default_render unless response_body
|
46
|
-
ret
|
47
|
-
end
|
48
|
-
|
49
|
-
def default_render
|
50
|
-
render
|
51
|
-
end
|
52
|
-
|
53
|
-
def method_for_action(action_name)
|
54
|
-
super || begin
|
55
|
-
if template_exists?(action_name.to_s, {:formats => formats}, :_prefix => controller_path)
|
56
|
-
"default_render"
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
include ImplicitRender
|
41
|
+
# Before callbacks should also be executed the earliest as possible, so
|
42
|
+
# also include them at the bottom.
|
43
|
+
include AbstractController::Callbacks
|
63
44
|
|
45
|
+
# The same with rescue, append it at the end to wrap as much as possible.
|
64
46
|
include ActionController::Rescue
|
65
47
|
|
66
48
|
def self.inherited(klass)
|
@@ -82,12 +64,8 @@ module ActionController
|
|
82
64
|
filter
|
83
65
|
end
|
84
66
|
|
85
|
-
|
86
|
-
|
87
|
-
# Overwrite url rewriter to use request.
|
88
|
-
def _url_rewriter
|
89
|
-
return ActionController::UrlRewriter unless request
|
90
|
-
@_url_rewriter ||= ActionController::UrlRewriter.new(request, params)
|
91
|
-
end
|
67
|
+
ActiveSupport.run_load_hooks(:action_controller, self)
|
92
68
|
end
|
93
69
|
end
|
70
|
+
|
71
|
+
require "action_controller/deprecated/base"
|
@@ -40,28 +40,34 @@ module ActionController #:nodoc:
|
|
40
40
|
autoload :Sweeping, 'action_controller/caching/sweeping'
|
41
41
|
end
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
# Defines the storage option for cached fragments
|
48
|
-
def self.cache_store=(store_option)
|
49
|
-
@@cache_store = ActiveSupport::Cache.lookup_store(store_option)
|
43
|
+
module ConfigMethods
|
44
|
+
def cache_store
|
45
|
+
config.cache_store
|
50
46
|
end
|
51
47
|
|
52
|
-
|
53
|
-
|
48
|
+
def cache_store=(store)
|
49
|
+
config.cache_store = ActiveSupport::Cache.lookup_store(store)
|
50
|
+
end
|
54
51
|
|
55
|
-
|
56
|
-
cattr_accessor :perform_caching
|
57
|
-
end
|
52
|
+
private
|
58
53
|
|
59
|
-
module ClassMethods
|
60
54
|
def cache_configured?
|
61
55
|
perform_caching && cache_store
|
62
56
|
end
|
63
57
|
end
|
64
58
|
|
59
|
+
include ConfigMethods
|
60
|
+
include Pages, Actions, Fragments
|
61
|
+
include Sweeping if defined?(ActiveRecord)
|
62
|
+
|
63
|
+
included do
|
64
|
+
extend ConfigMethods
|
65
|
+
|
66
|
+
@@perform_caching = true
|
67
|
+
cattr_accessor :perform_caching
|
68
|
+
end
|
69
|
+
|
70
|
+
|
65
71
|
def caching_allowed?
|
66
72
|
request.get? && response.status == 200
|
67
73
|
end
|
@@ -75,10 +81,5 @@ module ActionController #:nodoc:
|
|
75
81
|
yield
|
76
82
|
end
|
77
83
|
end
|
78
|
-
|
79
|
-
private
|
80
|
-
def cache_configured?
|
81
|
-
self.class.cache_configured?
|
82
|
-
end
|
83
84
|
end
|
84
85
|
end
|
@@ -80,6 +80,7 @@ module ActionController #:nodoc:
|
|
80
80
|
def caches_action(*actions)
|
81
81
|
return unless cache_configured?
|
82
82
|
options = actions.extract_options!
|
83
|
+
options[:layout] = true unless options.key?(:layout)
|
83
84
|
filter_options = options.extract!(:if, :unless).merge(:only => actions)
|
84
85
|
cache_options = options.extract!(:layout, :cache_path).merge(:store_options => options)
|
85
86
|
|
@@ -87,14 +88,12 @@ module ActionController #:nodoc:
|
|
87
88
|
end
|
88
89
|
end
|
89
90
|
|
90
|
-
def
|
91
|
-
render :text => cache, :layout => layout, :content_type => Mime[extension || :html]
|
92
|
-
end
|
93
|
-
|
94
|
-
def _save_fragment(name, layout, options)
|
91
|
+
def _save_fragment(name, options)
|
95
92
|
return unless caching_allowed?
|
96
93
|
|
97
|
-
content =
|
94
|
+
content = response_body
|
95
|
+
content = content.join if content.is_a?(Array)
|
96
|
+
|
98
97
|
write_fragment(name, content, options)
|
99
98
|
end
|
100
99
|
|
@@ -112,7 +111,7 @@ module ActionController #:nodoc:
|
|
112
111
|
|
113
112
|
class ActionCacheFilter #:nodoc:
|
114
113
|
def initialize(options, &block)
|
115
|
-
@cache_path, @store_options, @
|
114
|
+
@cache_path, @store_options, @cache_layout =
|
116
115
|
options.values_at(:cache_path, :store_options, :layout)
|
117
116
|
end
|
118
117
|
|
@@ -125,12 +124,19 @@ module ActionController #:nodoc:
|
|
125
124
|
|
126
125
|
cache_path = ActionCachePath.new(controller, path_options || {})
|
127
126
|
|
128
|
-
|
129
|
-
|
130
|
-
|
127
|
+
body = controller.read_fragment(cache_path.path, @store_options)
|
128
|
+
|
129
|
+
unless body
|
130
|
+
controller.action_has_layout = false unless @cache_layout
|
131
131
|
yield
|
132
|
-
controller.
|
132
|
+
controller.action_has_layout = true
|
133
|
+
body = controller._save_fragment(cache_path.path, @store_options)
|
133
134
|
end
|
135
|
+
|
136
|
+
body = controller.render_to_string(:text => cache, :layout => true) unless @cache_layout
|
137
|
+
|
138
|
+
controller.response_body = body
|
139
|
+
controller.content_type = Mime[cache_path.extension || :html]
|
134
140
|
end
|
135
141
|
end
|
136
142
|
|
@@ -34,26 +34,13 @@ module ActionController #:nodoc:
|
|
34
34
|
ActiveSupport::Cache.expand_cache_key(key.is_a?(Hash) ? url_for(key).split("://").last : key, :views)
|
35
35
|
end
|
36
36
|
|
37
|
-
def fragment_for(buffer, name = {}, options = nil, &block) #:nodoc:
|
38
|
-
if perform_caching
|
39
|
-
if fragment_exist?(name, options)
|
40
|
-
buffer.safe_concat(read_fragment(name, options))
|
41
|
-
else
|
42
|
-
pos = buffer.length
|
43
|
-
block.call
|
44
|
-
write_fragment(name, buffer[pos..-1], options)
|
45
|
-
end
|
46
|
-
else
|
47
|
-
block.call
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
37
|
# Writes <tt>content</tt> to the location signified by <tt>key</tt> (see <tt>expire_fragment</tt> for acceptable formats)
|
52
38
|
def write_fragment(key, content, options = nil)
|
53
39
|
return content unless cache_configured?
|
54
|
-
key = fragment_cache_key(key)
|
55
40
|
|
41
|
+
key = fragment_cache_key(key)
|
56
42
|
instrument_fragment_cache :write_fragment, key do
|
43
|
+
content = content.html_safe.to_str if content.respond_to?(:html_safe)
|
57
44
|
cache_store.write(key, content, options)
|
58
45
|
end
|
59
46
|
content
|
@@ -62,10 +49,11 @@ module ActionController #:nodoc:
|
|
62
49
|
# Reads a cached fragment from the location signified by <tt>key</tt> (see <tt>expire_fragment</tt> for acceptable formats)
|
63
50
|
def read_fragment(key, options = nil)
|
64
51
|
return unless cache_configured?
|
65
|
-
key = fragment_cache_key(key)
|
66
52
|
|
53
|
+
key = fragment_cache_key(key)
|
67
54
|
instrument_fragment_cache :read_fragment, key do
|
68
|
-
cache_store.read(key, options)
|
55
|
+
result = cache_store.read(key, options)
|
56
|
+
result.respond_to?(:html_safe) ? result.html_safe : result
|
69
57
|
end
|
70
58
|
end
|
71
59
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'uri'
|
3
|
+
require 'active_support/core_ext/class/attribute_accessors'
|
3
4
|
|
4
5
|
module ActionController #:nodoc:
|
5
6
|
module Caching
|
@@ -34,27 +35,26 @@ module ActionController #:nodoc:
|
|
34
35
|
# Additionally, you can expire caches using Sweepers that act on changes in the model to determine when a cache is supposed to be
|
35
36
|
# expired.
|
36
37
|
module Pages
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
38
|
+
extend ActiveSupport::Concern
|
39
|
+
|
40
|
+
included do
|
41
|
+
@@page_cache_directory = defined?(Rails.public_path) ? Rails.public_path : ""
|
42
|
+
##
|
43
|
+
# :singleton-method:
|
44
|
+
# The cache directory should be the document root for the web server and is set using <tt>Base.page_cache_directory = "/document/root"</tt>.
|
45
|
+
# For Rails, this directory has already been set to Rails.public_path (which is usually set to <tt>RAILS_ROOT + "/public"</tt>). Changing
|
46
|
+
# this setting can be useful to avoid naming conflicts with files in <tt>public/</tt>, but doing so will likely require configuring your
|
47
|
+
# web server to look in the new location for cached files.
|
48
|
+
cattr_accessor :page_cache_directory
|
49
|
+
|
50
|
+
@@page_cache_extension = '.html'
|
51
|
+
##
|
52
|
+
# :singleton-method:
|
53
|
+
# Most Rails requests do not have an extension, such as <tt>/weblog/new</tt>. In these cases, the page caching mechanism will add one in
|
54
|
+
# order to make it easy for the cached files to be picked up properly by the web server. By default, this cache extension is <tt>.html</tt>.
|
55
|
+
# If you want something else, like <tt>.php</tt> or <tt>.shtml</tt>, just set Base.page_cache_extension. In cases where a request already has an
|
56
|
+
# extension, such as <tt>.xml</tt> or <tt>.rss</tt>, page caching will not add an extension. This allows it to work well with RESTful apps.
|
57
|
+
cattr_accessor :page_cache_extension
|
58
58
|
end
|
59
59
|
|
60
60
|
module ClassMethods
|
@@ -121,10 +121,10 @@ module ActionController #:nodoc:
|
|
121
121
|
if options.is_a?(Hash)
|
122
122
|
if options[:action].is_a?(Array)
|
123
123
|
options[:action].dup.each do |action|
|
124
|
-
self.class.expire_page(url_for(options.merge(:only_path => true, :
|
124
|
+
self.class.expire_page(url_for(options.merge(:only_path => true, :action => action)))
|
125
125
|
end
|
126
126
|
else
|
127
|
-
self.class.expire_page(url_for(options.merge(:only_path => true
|
127
|
+
self.class.expire_page(url_for(options.merge(:only_path => true)))
|
128
128
|
end
|
129
129
|
else
|
130
130
|
self.class.expire_page(options)
|
@@ -139,7 +139,7 @@ module ActionController #:nodoc:
|
|
139
139
|
|
140
140
|
path = case options
|
141
141
|
when Hash
|
142
|
-
url_for(options.merge(:only_path => true, :
|
142
|
+
url_for(options.merge(:only_path => true, :format => params[:format]))
|
143
143
|
when String
|
144
144
|
options
|
145
145
|
else
|
@@ -30,9 +30,7 @@ module ActionController #:nodoc:
|
|
30
30
|
# cache_sweeper OpenBar::Sweeper, :only => [ :edit, :destroy, :share ]
|
31
31
|
# end
|
32
32
|
module Sweeping
|
33
|
-
|
34
|
-
base.extend(ClassMethods)
|
35
|
-
end
|
33
|
+
extend ActiveSupport::Concern
|
36
34
|
|
37
35
|
module ClassMethods #:nodoc:
|
38
36
|
def cache_sweeper(*sweepers)
|
@@ -1,5 +1,3 @@
|
|
1
1
|
ActionController::AbstractRequest = ActionController::Request = ActionDispatch::Request
|
2
2
|
ActionController::AbstractResponse = ActionController::Response = ActionDispatch::Response
|
3
3
|
ActionController::Routing = ActionDispatch::Routing
|
4
|
-
ActionController::Routing::Routes = ActionDispatch::Routing::RouteSet.new
|
5
|
-
ActionController::UrlWriter = ActionController::UrlFor
|
@@ -0,0 +1,143 @@
|
|
1
|
+
module ActionController
|
2
|
+
class Base
|
3
|
+
class << self
|
4
|
+
def deprecated_config_accessor(option, message = nil)
|
5
|
+
deprecated_config_reader(option, message)
|
6
|
+
deprecated_config_writer(option, message)
|
7
|
+
end
|
8
|
+
|
9
|
+
def deprecated_config_reader(option, message = nil)
|
10
|
+
message ||= "Reading #{option} directly from ActionController::Base is deprecated. " \
|
11
|
+
"Please read it from config.#{option}"
|
12
|
+
|
13
|
+
self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
14
|
+
def #{option}
|
15
|
+
ActiveSupport::Deprecation.warn #{message.inspect}, caller
|
16
|
+
config.#{option}
|
17
|
+
end
|
18
|
+
RUBY
|
19
|
+
end
|
20
|
+
|
21
|
+
def deprecated_config_writer(option, message = nil)
|
22
|
+
message ||= "Setting #{option} directly on ActionController::Base is deprecated. " \
|
23
|
+
"Please set it on config.action_controller.#{option}"
|
24
|
+
|
25
|
+
self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
26
|
+
def #{option}=(val)
|
27
|
+
ActiveSupport::Deprecation.warn #{message.inspect}, caller
|
28
|
+
config.#{option} = val
|
29
|
+
end
|
30
|
+
RUBY
|
31
|
+
end
|
32
|
+
|
33
|
+
def consider_all_requests_local
|
34
|
+
ActiveSupport::Deprecation.warn "ActionController::Base.consider_all_requests_local is deprecated, " <<
|
35
|
+
"use Rails.application.config.consider_all_requests_local instead", caller
|
36
|
+
Rails.application.config.consider_all_requests_local
|
37
|
+
end
|
38
|
+
|
39
|
+
def consider_all_requests_local=(value)
|
40
|
+
ActiveSupport::Deprecation.warn "ActionController::Base.consider_all_requests_local= is deprecated. " <<
|
41
|
+
"Please configure it on your application with config.consider_all_requests_local=", caller
|
42
|
+
Rails.application.config.consider_all_requests_local = value
|
43
|
+
end
|
44
|
+
|
45
|
+
def allow_concurrency
|
46
|
+
ActiveSupport::Deprecation.warn "ActionController::Base.allow_concurrency is deprecated, " <<
|
47
|
+
"use Rails.application.config.allow_concurrency instead", caller
|
48
|
+
Rails.application.config.allow_concurrency
|
49
|
+
end
|
50
|
+
|
51
|
+
def allow_concurrency=(value)
|
52
|
+
ActiveSupport::Deprecation.warn "ActionController::Base.allow_concurrency= is deprecated. " <<
|
53
|
+
"Please configure it on your application with config.allow_concurrency=", caller
|
54
|
+
Rails.application.config.allow_concurrency = value
|
55
|
+
end
|
56
|
+
|
57
|
+
def ip_spoofing_check=(value)
|
58
|
+
ActiveSupport::Deprecation.warn "ActionController::Base.ip_spoofing_check= is deprecated. " <<
|
59
|
+
"Please configure it on your application with config.action_dispatch.ip_spoofing_check=", caller
|
60
|
+
Rails.application.config.action_dispatch.ip_spoofing_check = value
|
61
|
+
end
|
62
|
+
|
63
|
+
def ip_spoofing_check
|
64
|
+
ActiveSupport::Deprecation.warn "ActionController::Base.ip_spoofing_check is deprecated. " <<
|
65
|
+
"Configuring ip_spoofing_check on the application configures a middleware.", caller
|
66
|
+
Rails.application.config.action_dispatch.ip_spoofing_check
|
67
|
+
end
|
68
|
+
|
69
|
+
def cookie_verifier_secret=(value)
|
70
|
+
ActiveSupport::Deprecation.warn "ActionController::Base.cookie_verifier_secret= is deprecated. " <<
|
71
|
+
"Please configure it on your application with config.cookie_secret=", caller
|
72
|
+
ActionController::Base.config.secret = value
|
73
|
+
end
|
74
|
+
|
75
|
+
def cookie_verifier_secret
|
76
|
+
ActiveSupport::Deprecation.warn "ActionController::Base.cookie_verifier_secret is deprecated. " <<
|
77
|
+
"Please use ActionController::Base.config.secret instead.", caller
|
78
|
+
ActionController::Base.config.secret
|
79
|
+
end
|
80
|
+
|
81
|
+
def trusted_proxies=(value)
|
82
|
+
ActiveSupport::Deprecation.warn "ActionController::Base.trusted_proxies= is deprecated. " <<
|
83
|
+
"Please configure it on your application with config.action_dispatch.trusted_proxies=", caller
|
84
|
+
Rails.application.config.action_dispatch.ip_spoofing_check = value
|
85
|
+
end
|
86
|
+
|
87
|
+
def trusted_proxies
|
88
|
+
ActiveSupport::Deprecation.warn "ActionController::Base.trusted_proxies is deprecated. " <<
|
89
|
+
"Configuring trusted_proxies on the application configures a middleware.", caller
|
90
|
+
Rails.application.config.action_dispatch.ip_spoofing_check = value
|
91
|
+
end
|
92
|
+
|
93
|
+
def session(*args)
|
94
|
+
ActiveSupport::Deprecation.warn(
|
95
|
+
"Disabling sessions for a single controller has been deprecated. " +
|
96
|
+
"Sessions are now lazy loaded. So if you don't access them, " +
|
97
|
+
"consider them off. You can still modify the session cookie " +
|
98
|
+
"options with request.session_options.", caller)
|
99
|
+
end
|
100
|
+
|
101
|
+
def session=(value)
|
102
|
+
ActiveSupport::Deprecation.warn "ActionController::Base.session= is deprecated. " <<
|
103
|
+
"Please configure it on your application with config.session_store :cookie_store, :key => '....'", caller
|
104
|
+
if value.delete(:disabled)
|
105
|
+
Rails.application.config.session_store :disabled
|
106
|
+
else
|
107
|
+
store = Rails.application.config.session_store
|
108
|
+
Rails.application.config.session_store store, value
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# Controls the resource action separator
|
113
|
+
def resource_action_separator
|
114
|
+
@resource_action_separator ||= "/"
|
115
|
+
end
|
116
|
+
|
117
|
+
def resource_action_separator=(val)
|
118
|
+
ActiveSupport::Deprecation.warn "ActionController::Base.resource_action_separator is deprecated and only " \
|
119
|
+
"works with the deprecated router DSL."
|
120
|
+
@resource_action_separator = val
|
121
|
+
end
|
122
|
+
|
123
|
+
def use_accept_header
|
124
|
+
ActiveSupport::Deprecation.warn "ActionController::Base.use_accept_header doesn't do anything anymore. " \
|
125
|
+
"The accept header is always taken into account."
|
126
|
+
end
|
127
|
+
|
128
|
+
def use_accept_header=(val)
|
129
|
+
use_accept_header
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
deprecated_config_writer :session_store
|
134
|
+
deprecated_config_writer :session_options
|
135
|
+
deprecated_config_accessor :relative_url_root, "relative_url_root is ineffective. Please stop using it"
|
136
|
+
deprecated_config_accessor :assets_dir
|
137
|
+
deprecated_config_accessor :javascripts_dir
|
138
|
+
deprecated_config_accessor :stylesheets_dir
|
139
|
+
|
140
|
+
delegate :consider_all_requests_local, :consider_all_requests_local=,
|
141
|
+
:allow_concurrency, :allow_concurrency=, :to => :"self.class"
|
142
|
+
end
|
143
|
+
end
|