actionpack 3.0.0.beta4 → 3.0.0.rc

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.

Files changed (102) hide show
  1. data/CHANGELOG +36 -0
  2. data/{README → README.rdoc} +79 -137
  3. data/lib/abstract_controller.rb +1 -0
  4. data/lib/abstract_controller/asset_paths.rb +1 -1
  5. data/lib/abstract_controller/base.rb +3 -12
  6. data/lib/abstract_controller/rendering.rb +2 -2
  7. data/lib/abstract_controller/view_paths.rb +2 -1
  8. data/lib/action_controller.rb +1 -2
  9. data/lib/action_controller/base.rb +3 -9
  10. data/lib/action_controller/log_subscriber.rb +56 -0
  11. data/lib/action_controller/metal.rb +10 -3
  12. data/lib/action_controller/metal/helpers.rb +5 -4
  13. data/lib/action_controller/metal/hide_actions.rb +3 -3
  14. data/lib/action_controller/metal/instrumentation.rb +2 -1
  15. data/lib/action_controller/metal/mime_responds.rb +13 -10
  16. data/lib/action_controller/metal/rack_delegation.rb +0 -4
  17. data/lib/action_controller/metal/request_forgery_protection.rb +1 -1
  18. data/lib/action_controller/metal/rescue.rb +9 -0
  19. data/lib/action_controller/metal/responder.rb +13 -5
  20. data/lib/action_controller/metal/streaming.rb +2 -0
  21. data/lib/action_controller/metal/url_for.rb +5 -5
  22. data/lib/action_controller/railtie.rb +14 -23
  23. data/lib/action_controller/record_identifier.rb +6 -25
  24. data/lib/action_controller/test_case.rb +18 -6
  25. data/lib/action_controller/vendor/html-scanner/html/node.rb +1 -0
  26. data/lib/action_controller/vendor/html-scanner/html/tokenizer.rb +1 -0
  27. data/lib/action_dispatch.rb +6 -0
  28. data/lib/action_dispatch/http/cache.rb +2 -2
  29. data/lib/action_dispatch/http/filter_parameters.rb +10 -66
  30. data/lib/action_dispatch/http/mime_type.rb +1 -1
  31. data/lib/action_dispatch/http/parameter_filter.rb +72 -0
  32. data/lib/action_dispatch/http/parameters.rb +31 -2
  33. data/lib/action_dispatch/http/request.rb +4 -1
  34. data/lib/action_dispatch/http/upload.rb +2 -2
  35. data/lib/action_dispatch/middleware/callbacks.rb +4 -4
  36. data/lib/action_dispatch/middleware/cookies.rb +39 -6
  37. data/lib/action_dispatch/middleware/flash.rb +9 -2
  38. data/lib/action_dispatch/middleware/session/abstract_store.rb +121 -36
  39. data/lib/action_dispatch/middleware/session/cookie_store.rb +26 -19
  40. data/lib/action_dispatch/middleware/session/mem_cache_store.rb +9 -1
  41. data/lib/action_dispatch/middleware/show_exceptions.rb +2 -2
  42. data/lib/action_dispatch/middleware/stack.rb +12 -5
  43. data/lib/action_dispatch/railtie.rb +1 -1
  44. data/lib/action_dispatch/routing.rb +11 -13
  45. data/lib/action_dispatch/routing/deprecated_mapper.rb +6 -388
  46. data/lib/action_dispatch/routing/mapper.rb +364 -234
  47. data/lib/action_dispatch/routing/polymorphic_routes.rb +186 -0
  48. data/lib/action_dispatch/routing/route.rb +11 -2
  49. data/lib/action_dispatch/routing/route_set.rb +62 -28
  50. data/lib/action_dispatch/routing/url_for.rb +2 -1
  51. data/lib/action_dispatch/testing/assertions.rb +0 -2
  52. data/lib/action_dispatch/testing/assertions/routing.rb +0 -1
  53. data/lib/action_dispatch/testing/assertions/selector.rb +20 -24
  54. data/lib/action_dispatch/testing/integration.rb +2 -2
  55. data/lib/action_dispatch/testing/test_response.rb +2 -2
  56. data/lib/action_pack/version.rb +1 -1
  57. data/lib/action_view.rb +1 -0
  58. data/lib/action_view/base.rb +20 -21
  59. data/lib/action_view/context.rb +9 -12
  60. data/lib/action_view/helpers.rb +0 -2
  61. data/lib/action_view/helpers/active_model_helper.rb +17 -2
  62. data/lib/action_view/helpers/asset_tag_helper.rb +15 -33
  63. data/lib/action_view/helpers/atom_feed_helper.rb +5 -3
  64. data/lib/action_view/helpers/cache_helper.rb +4 -2
  65. data/lib/action_view/helpers/capture_helper.rb +4 -4
  66. data/lib/action_view/helpers/csrf_helper.rb +3 -1
  67. data/lib/action_view/helpers/date_helper.rb +10 -5
  68. data/lib/action_view/helpers/debug_helper.rb +3 -1
  69. data/lib/action_view/helpers/form_helper.rb +36 -30
  70. data/lib/action_view/helpers/form_options_helper.rb +7 -6
  71. data/lib/action_view/helpers/form_tag_helper.rb +17 -6
  72. data/lib/action_view/helpers/javascript_helper.rb +1 -0
  73. data/lib/action_view/helpers/number_helper.rb +16 -45
  74. data/lib/action_view/helpers/prototype_helper.rb +14 -16
  75. data/lib/action_view/helpers/raw_output_helper.rb +9 -0
  76. data/lib/action_view/helpers/record_tag_helper.rb +5 -0
  77. data/lib/action_view/helpers/sanitize_helper.rb +26 -20
  78. data/lib/action_view/helpers/scriptaculous_helper.rb +6 -5
  79. data/lib/action_view/helpers/tag_helper.rb +2 -1
  80. data/lib/action_view/helpers/text_helper.rb +24 -111
  81. data/lib/action_view/helpers/translation_helper.rb +17 -10
  82. data/lib/action_view/helpers/url_helper.rb +26 -33
  83. data/lib/action_view/log_subscriber.rb +28 -0
  84. data/lib/action_view/lookup_context.rb +2 -0
  85. data/lib/action_view/paths.rb +1 -0
  86. data/lib/action_view/railtie.rb +15 -3
  87. data/lib/action_view/render/layouts.rb +2 -1
  88. data/lib/action_view/render/partials.rb +3 -1
  89. data/lib/action_view/render/rendering.rb +2 -1
  90. data/lib/action_view/template.rb +12 -8
  91. data/lib/action_view/template/error.rb +1 -0
  92. data/lib/action_view/template/handlers.rb +1 -0
  93. data/lib/action_view/template/resolver.rb +2 -1
  94. data/lib/action_view/template/text.rb +1 -0
  95. data/lib/action_view/test_case.rb +42 -20
  96. metadata +44 -23
  97. data/lib/action_controller/polymorphic_routes.rb +0 -182
  98. data/lib/action_controller/railties/log_subscriber.rb +0 -56
  99. data/lib/action_controller/railties/url_helpers.rb +0 -14
  100. data/lib/action_dispatch/testing/assertions/model.rb +0 -19
  101. data/lib/action_view/helpers/record_identification_helper.rb +0 -20
  102. data/lib/action_view/railties/log_subscriber.rb +0 -24
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionpack
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 7712042
4
5
  prerelease: true
5
6
  segments:
6
7
  - 3
7
8
  - 0
8
9
  - 0
9
- - beta4
10
- version: 3.0.0.beta4
10
+ - rc
11
+ version: 3.0.0.rc
11
12
  platform: ruby
12
13
  authors:
13
14
  - David Heinemeier Hansson
@@ -15,46 +16,52 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-06-08 00:00:00 -04:00
19
+ date: 2010-07-26 00:00:00 -05:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
22
23
  name: activesupport
23
24
  prerelease: false
24
25
  requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
25
27
  requirements:
26
28
  - - "="
27
29
  - !ruby/object:Gem::Version
30
+ hash: 7712042
28
31
  segments:
29
32
  - 3
30
33
  - 0
31
34
  - 0
32
- - beta4
33
- version: 3.0.0.beta4
35
+ - rc
36
+ version: 3.0.0.rc
34
37
  type: :runtime
35
38
  version_requirements: *id001
36
39
  - !ruby/object:Gem::Dependency
37
40
  name: activemodel
38
41
  prerelease: false
39
42
  requirement: &id002 !ruby/object:Gem::Requirement
43
+ none: false
40
44
  requirements:
41
45
  - - "="
42
46
  - !ruby/object:Gem::Version
47
+ hash: 7712042
43
48
  segments:
44
49
  - 3
45
50
  - 0
46
51
  - 0
47
- - beta4
48
- version: 3.0.0.beta4
52
+ - rc
53
+ version: 3.0.0.rc
49
54
  type: :runtime
50
55
  version_requirements: *id002
51
56
  - !ruby/object:Gem::Dependency
52
57
  name: builder
53
58
  prerelease: false
54
59
  requirement: &id003 !ruby/object:Gem::Requirement
60
+ none: false
55
61
  requirements:
56
62
  - - ~>
57
63
  - !ruby/object:Gem::Version
64
+ hash: 15
58
65
  segments:
59
66
  - 2
60
67
  - 1
@@ -66,9 +73,11 @@ dependencies:
66
73
  name: i18n
67
74
  prerelease: false
68
75
  requirement: &id004 !ruby/object:Gem::Requirement
76
+ none: false
69
77
  requirements:
70
78
  - - ~>
71
79
  - !ruby/object:Gem::Version
80
+ hash: 13
72
81
  segments:
73
82
  - 0
74
83
  - 4
@@ -80,23 +89,27 @@ dependencies:
80
89
  name: rack
81
90
  prerelease: false
82
91
  requirement: &id005 !ruby/object:Gem::Requirement
92
+ none: false
83
93
  requirements:
84
94
  - - ~>
85
95
  - !ruby/object:Gem::Version
96
+ hash: 29
86
97
  segments:
87
98
  - 1
99
+ - 2
88
100
  - 1
89
- - 0
90
- version: 1.1.0
101
+ version: 1.2.1
91
102
  type: :runtime
92
103
  version_requirements: *id005
93
104
  - !ruby/object:Gem::Dependency
94
105
  name: rack-test
95
106
  prerelease: false
96
107
  requirement: &id006 !ruby/object:Gem::Requirement
108
+ none: false
97
109
  requirements:
98
110
  - - ~>
99
111
  - !ruby/object:Gem::Version
112
+ hash: 3
100
113
  segments:
101
114
  - 0
102
115
  - 5
@@ -108,42 +121,48 @@ dependencies:
108
121
  name: rack-mount
109
122
  prerelease: false
110
123
  requirement: &id007 !ruby/object:Gem::Requirement
124
+ none: false
111
125
  requirements:
112
126
  - - ~>
113
127
  - !ruby/object:Gem::Version
128
+ hash: 21
114
129
  segments:
115
130
  - 0
116
131
  - 6
117
- - 3
118
- version: 0.6.3
132
+ - 9
133
+ version: 0.6.9
119
134
  type: :runtime
120
135
  version_requirements: *id007
121
136
  - !ruby/object:Gem::Dependency
122
137
  name: tzinfo
123
138
  prerelease: false
124
139
  requirement: &id008 !ruby/object:Gem::Requirement
140
+ none: false
125
141
  requirements:
126
142
  - - ~>
127
143
  - !ruby/object:Gem::Version
144
+ hash: 63
128
145
  segments:
129
146
  - 0
130
147
  - 3
131
- - 16
132
- version: 0.3.16
148
+ - 22
149
+ version: 0.3.22
133
150
  type: :runtime
134
151
  version_requirements: *id008
135
152
  - !ruby/object:Gem::Dependency
136
153
  name: erubis
137
154
  prerelease: false
138
155
  requirement: &id009 !ruby/object:Gem::Requirement
156
+ none: false
139
157
  requirements:
140
158
  - - ~>
141
159
  - !ruby/object:Gem::Version
160
+ hash: 27
142
161
  segments:
143
162
  - 2
144
163
  - 6
145
- - 5
146
- version: 2.6.5
164
+ - 6
165
+ version: 2.6.6
147
166
  type: :runtime
148
167
  version_requirements: *id009
149
168
  description: Web apps on Rails. Simple, battle-tested conventions for building and testing MVC web applications. Works with any Rack-compatible server.
@@ -156,7 +175,7 @@ extra_rdoc_files: []
156
175
 
157
176
  files:
158
177
  - CHANGELOG
159
- - README
178
+ - README.rdoc
160
179
  - MIT-LICENSE
161
180
  - lib/abstract_controller/asset_paths.rb
162
181
  - lib/abstract_controller/base.rb
@@ -180,6 +199,7 @@ files:
180
199
  - lib/action_controller/deprecated/integration_test.rb
181
200
  - lib/action_controller/deprecated/performance_test.rb
182
201
  - lib/action_controller/deprecated.rb
202
+ - lib/action_controller/log_subscriber.rb
183
203
  - lib/action_controller/metal/compatibility.rb
184
204
  - lib/action_controller/metal/conditional_get.rb
185
205
  - lib/action_controller/metal/cookies.rb
@@ -205,10 +225,7 @@ files:
205
225
  - lib/action_controller/metal/url_for.rb
206
226
  - lib/action_controller/metal.rb
207
227
  - lib/action_controller/middleware.rb
208
- - lib/action_controller/polymorphic_routes.rb
209
228
  - lib/action_controller/railtie.rb
210
- - lib/action_controller/railties/log_subscriber.rb
211
- - lib/action_controller/railties/url_helpers.rb
212
229
  - lib/action_controller/record_identifier.rb
213
230
  - lib/action_controller/test_case.rb
214
231
  - lib/action_controller/vendor/html-scanner/html/document.rb
@@ -225,6 +242,7 @@ files:
225
242
  - lib/action_dispatch/http/mime_negotiation.rb
226
243
  - lib/action_dispatch/http/mime_type.rb
227
244
  - lib/action_dispatch/http/mime_types.rb
245
+ - lib/action_dispatch/http/parameter_filter.rb
228
246
  - lib/action_dispatch/http/parameters.rb
229
247
  - lib/action_dispatch/http/request.rb
230
248
  - lib/action_dispatch/http/response.rb
@@ -254,12 +272,12 @@ files:
254
272
  - lib/action_dispatch/railtie.rb
255
273
  - lib/action_dispatch/routing/deprecated_mapper.rb
256
274
  - lib/action_dispatch/routing/mapper.rb
275
+ - lib/action_dispatch/routing/polymorphic_routes.rb
257
276
  - lib/action_dispatch/routing/route.rb
258
277
  - lib/action_dispatch/routing/route_set.rb
259
278
  - lib/action_dispatch/routing/url_for.rb
260
279
  - lib/action_dispatch/routing.rb
261
280
  - lib/action_dispatch/testing/assertions/dom.rb
262
- - lib/action_dispatch/testing/assertions/model.rb
263
281
  - lib/action_dispatch/testing/assertions/response.rb
264
282
  - lib/action_dispatch/testing/assertions/routing.rb
265
283
  - lib/action_dispatch/testing/assertions/selector.rb
@@ -290,7 +308,6 @@ files:
290
308
  - lib/action_view/helpers/number_helper.rb
291
309
  - lib/action_view/helpers/prototype_helper.rb
292
310
  - lib/action_view/helpers/raw_output_helper.rb
293
- - lib/action_view/helpers/record_identification_helper.rb
294
311
  - lib/action_view/helpers/record_tag_helper.rb
295
312
  - lib/action_view/helpers/sanitize_helper.rb
296
313
  - lib/action_view/helpers/scriptaculous_helper.rb
@@ -300,10 +317,10 @@ files:
300
317
  - lib/action_view/helpers/url_helper.rb
301
318
  - lib/action_view/helpers.rb
302
319
  - lib/action_view/locale/en.yml
320
+ - lib/action_view/log_subscriber.rb
303
321
  - lib/action_view/lookup_context.rb
304
322
  - lib/action_view/paths.rb
305
323
  - lib/action_view/railtie.rb
306
- - lib/action_view/railties/log_subscriber.rb
307
324
  - lib/action_view/render/layouts.rb
308
325
  - lib/action_view/render/partials.rb
309
326
  - lib/action_view/render/rendering.rb
@@ -329,18 +346,22 @@ rdoc_options: []
329
346
  require_paths:
330
347
  - lib
331
348
  required_ruby_version: !ruby/object:Gem::Requirement
349
+ none: false
332
350
  requirements:
333
351
  - - ">="
334
352
  - !ruby/object:Gem::Version
353
+ hash: 57
335
354
  segments:
336
355
  - 1
337
356
  - 8
338
357
  - 7
339
358
  version: 1.8.7
340
359
  required_rubygems_version: !ruby/object:Gem::Requirement
360
+ none: false
341
361
  requirements:
342
362
  - - ">"
343
363
  - !ruby/object:Gem::Version
364
+ hash: 25
344
365
  segments:
345
366
  - 1
346
367
  - 3
@@ -349,7 +370,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
349
370
  requirements:
350
371
  - none
351
372
  rubyforge_project: actionpack
352
- rubygems_version: 1.3.6
373
+ rubygems_version: 1.3.7
353
374
  signing_key:
354
375
  specification_version: 3
355
376
  summary: Web-flow and rendering framework putting the VC in MVC (part of Rails).
@@ -1,182 +0,0 @@
1
- module ActionController
2
- # Polymorphic URL helpers are methods for smart resolution to a named route call when
3
- # given an Active Record model instance. They are to be used in combination with
4
- # ActionController::Resources.
5
- #
6
- # These methods are useful when you want to generate correct URL or path to a RESTful
7
- # resource without having to know the exact type of the record in question.
8
- #
9
- # Nested resources and/or namespaces are also supported, as illustrated in the example:
10
- #
11
- # polymorphic_url([:admin, @article, @comment])
12
- #
13
- # results in:
14
- #
15
- # admin_article_comment_url(@article, @comment)
16
- #
17
- # == Usage within the framework
18
- #
19
- # Polymorphic URL helpers are used in a number of places throughout the Rails framework:
20
- #
21
- # * <tt>url_for</tt>, so you can use it with a record as the argument, e.g.
22
- # <tt>url_for(@article)</tt>;
23
- # * ActionView::Helpers::FormHelper uses <tt>polymorphic_path</tt>, so you can write
24
- # <tt>form_for(@article)</tt> without having to specify <tt>:url</tt> parameter for the form
25
- # action;
26
- # * <tt>redirect_to</tt> (which, in fact, uses <tt>url_for</tt>) so you can write
27
- # <tt>redirect_to(post)</tt> in your controllers;
28
- # * ActionView::Helpers::AtomFeedHelper, so you don't have to explicitly specify URLs
29
- # for feed entries.
30
- #
31
- # == Prefixed polymorphic helpers
32
- #
33
- # In addition to <tt>polymorphic_url</tt> and <tt>polymorphic_path</tt> methods, a
34
- # number of prefixed helpers are available as a shorthand to <tt>:action => "..."</tt>
35
- # in options. Those are:
36
- #
37
- # * <tt>edit_polymorphic_url</tt>, <tt>edit_polymorphic_path</tt>
38
- # * <tt>new_polymorphic_url</tt>, <tt>new_polymorphic_path</tt>
39
- #
40
- # Example usage:
41
- #
42
- # edit_polymorphic_path(@post) # => "/posts/1/edit"
43
- # polymorphic_path(@post, :format => :pdf) # => "/posts/1.pdf"
44
- module PolymorphicRoutes
45
- # Constructs a call to a named RESTful route for the given record and returns the
46
- # resulting URL string. For example:
47
- #
48
- # # calls post_url(post)
49
- # polymorphic_url(post) # => "http://example.com/posts/1"
50
- # polymorphic_url([blog, post]) # => "http://example.com/blogs/1/posts/1"
51
- # polymorphic_url([:admin, blog, post]) # => "http://example.com/admin/blogs/1/posts/1"
52
- # polymorphic_url([user, :blog, post]) # => "http://example.com/users/1/blog/posts/1"
53
- # polymorphic_url(Comment) # => "http://example.com/comments"
54
- #
55
- # ==== Options
56
- #
57
- # * <tt>:action</tt> - Specifies the action prefix for the named route:
58
- # <tt>:new</tt> or <tt>:edit</tt>. Default is no prefix.
59
- # * <tt>:routing_type</tt> - Allowed values are <tt>:path</tt> or <tt>:url</tt>.
60
- # Default is <tt>:url</tt>.
61
- #
62
- # ==== Examples
63
- #
64
- # # an Article record
65
- # polymorphic_url(record) # same as article_url(record)
66
- #
67
- # # a Comment record
68
- # polymorphic_url(record) # same as comment_url(record)
69
- #
70
- # # it recognizes new records and maps to the collection
71
- # record = Comment.new
72
- # polymorphic_url(record) # same as comments_url()
73
- #
74
- # # the class of a record will also map to the collection
75
- # polymorphic_url(Comment) # same as comments_url()
76
- #
77
- def polymorphic_url(record_or_hash_or_array, options = {})
78
- if record_or_hash_or_array.kind_of?(Array)
79
- record_or_hash_or_array = record_or_hash_or_array.compact
80
- record_or_hash_or_array = record_or_hash_or_array[0] if record_or_hash_or_array.size == 1
81
- end
82
-
83
- record = extract_record(record_or_hash_or_array)
84
- record = record.to_model if record.respond_to?(:to_model)
85
-
86
- args = case record_or_hash_or_array
87
- when Hash; [ record_or_hash_or_array ]
88
- when Array; record_or_hash_or_array.dup
89
- else [ record_or_hash_or_array ]
90
- end
91
-
92
- inflection = if options[:action].to_s == "new"
93
- args.pop
94
- :singular
95
- elsif (record.respond_to?(:persisted?) && !record.persisted?)
96
- args.pop
97
- :plural
98
- elsif record.is_a?(Class)
99
- args.pop
100
- :plural
101
- else
102
- :singular
103
- end
104
-
105
- args.delete_if {|arg| arg.is_a?(Symbol) || arg.is_a?(String)}
106
- named_route = build_named_route_call(record_or_hash_or_array, inflection, options)
107
-
108
- url_options = options.except(:action, :routing_type)
109
- unless url_options.empty?
110
- args.last.kind_of?(Hash) ? args.last.merge!(url_options) : args << url_options
111
- end
112
-
113
- __send__(named_route, *args)
114
- end
115
-
116
- # Returns the path component of a URL for the given record. It uses
117
- # <tt>polymorphic_url</tt> with <tt>:routing_type => :path</tt>.
118
- def polymorphic_path(record_or_hash_or_array, options = {})
119
- polymorphic_url(record_or_hash_or_array, options.merge(:routing_type => :path))
120
- end
121
-
122
- %w(edit new).each do |action|
123
- module_eval <<-EOT, __FILE__, __LINE__ + 1
124
- def #{action}_polymorphic_url(record_or_hash, options = {}) # def edit_polymorphic_url(record_or_hash, options = {})
125
- polymorphic_url( # polymorphic_url(
126
- record_or_hash, # record_or_hash,
127
- options.merge(:action => "#{action}")) # options.merge(:action => "edit"))
128
- end # end
129
- #
130
- def #{action}_polymorphic_path(record_or_hash, options = {}) # def edit_polymorphic_path(record_or_hash, options = {})
131
- polymorphic_url( # polymorphic_url(
132
- record_or_hash, # record_or_hash,
133
- options.merge(:action => "#{action}", :routing_type => :path)) # options.merge(:action => "edit", :routing_type => :path))
134
- end # end
135
- EOT
136
- end
137
-
138
- private
139
- def action_prefix(options)
140
- options[:action] ? "#{options[:action]}_" : ''
141
- end
142
-
143
- def routing_type(options)
144
- options[:routing_type] || :url
145
- end
146
-
147
- def build_named_route_call(records, inflection, options = {})
148
- unless records.is_a?(Array)
149
- record = extract_record(records)
150
- route = ''
151
- else
152
- record = records.pop
153
- route = records.inject("") do |string, parent|
154
- if parent.is_a?(Symbol) || parent.is_a?(String)
155
- string << "#{parent}_"
156
- else
157
- string << RecordIdentifier.__send__("plural_class_name", parent).singularize
158
- string << "_"
159
- end
160
- end
161
- end
162
-
163
- if record.is_a?(Symbol) || record.is_a?(String)
164
- route << "#{record}_"
165
- else
166
- route << RecordIdentifier.__send__("plural_class_name", record)
167
- route = route.singularize if inflection == :singular
168
- route << "_"
169
- end
170
-
171
- action_prefix(options) + route + routing_type(options).to_s
172
- end
173
-
174
- def extract_record(record_or_hash_or_array)
175
- case record_or_hash_or_array
176
- when Array; record_or_hash_or_array.last
177
- when Hash; record_or_hash_or_array[:id]
178
- else record_or_hash_or_array
179
- end
180
- end
181
- end
182
- end
@@ -1,56 +0,0 @@
1
- require 'active_support/core_ext/object/blank'
2
-
3
- module ActionController
4
- module Railties
5
- class LogSubscriber < Rails::LogSubscriber
6
- INTERNAL_PARAMS = %w(controller action format _method only_path)
7
-
8
- def start_processing(event)
9
- payload = event.payload
10
- params = payload[:params].except(*INTERNAL_PARAMS)
11
-
12
- info " Processing by #{payload[:controller]}##{payload[:action]} as #{payload[:formats].first.to_s.upcase}"
13
- info " Parameters: #{params.inspect}" unless params.empty?
14
- end
15
-
16
- def process_action(event)
17
- payload = event.payload
18
- additions = ActionController::Base.log_process_action(payload)
19
-
20
- message = "Completed #{payload[:status]} #{Rack::Utils::HTTP_STATUS_CODES[payload[:status]]} in %.0fms" % event.duration
21
- message << " (#{additions.join(" | ")})" unless additions.blank?
22
-
23
- info(message)
24
- end
25
-
26
- def send_file(event)
27
- message = "Sent file %s"
28
- message << " (%.1fms)"
29
- info(message % [event.payload[:path], event.duration])
30
- end
31
-
32
- def redirect_to(event)
33
- info "Redirected to #{event.payload[:location]}"
34
- end
35
-
36
- def send_data(event)
37
- info("Sent data %s (%.1fms)" % [event.payload[:filename], event.duration])
38
- end
39
-
40
- %w(write_fragment read_fragment exist_fragment?
41
- expire_fragment expire_page write_page).each do |method|
42
- class_eval <<-METHOD, __FILE__, __LINE__ + 1
43
- def #{method}(event)
44
- key_or_path = event.payload[:key] || event.payload[:path]
45
- human_name = #{method.to_s.humanize.inspect}
46
- info("\#{human_name} \#{key_or_path} (%.1fms)" % event.duration)
47
- end
48
- METHOD
49
- end
50
-
51
- def logger
52
- ActionController::Base.logger
53
- end
54
- end
55
- end
56
- end