actionpack 1.13.3 → 1.13.4

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 (47) hide show
  1. data/CHANGELOG +44 -2
  2. data/Rakefile +1 -1
  3. data/lib/action_controller/assertions/dom_assertions.rb +2 -2
  4. data/lib/action_controller/assertions/model_assertions.rb +1 -1
  5. data/lib/action_controller/assertions/response_assertions.rb +2 -0
  6. data/lib/action_controller/assertions/routing_assertions.rb +1 -0
  7. data/lib/action_controller/base.rb +7 -1
  8. data/lib/action_controller/caching.rb +39 -38
  9. data/lib/action_controller/cgi_ext/pstore_performance_fix.rb +30 -0
  10. data/lib/action_controller/cgi_ext/raw_post_data_fix.rb +1 -1
  11. data/lib/action_controller/cgi_process.rb +13 -4
  12. data/lib/action_controller/cookies.rb +5 -3
  13. data/lib/action_controller/filters.rb +176 -77
  14. data/lib/action_controller/integration.rb +31 -21
  15. data/lib/action_controller/pagination.rb +7 -1
  16. data/lib/action_controller/resources.rb +117 -32
  17. data/lib/action_controller/routing.rb +41 -1
  18. data/lib/action_controller/test_process.rb +5 -2
  19. data/lib/action_controller/url_rewriter.rb +4 -1
  20. data/lib/action_controller/verification.rb +1 -0
  21. data/lib/action_pack/version.rb +1 -1
  22. data/lib/action_view/base.rb +25 -19
  23. data/lib/action_view/compiled_templates.rb +2 -2
  24. data/lib/action_view/helpers/active_record_helper.rb +18 -18
  25. data/lib/action_view/helpers/debug_helper.rb +10 -0
  26. data/lib/action_view/helpers/deprecated_helper.rb +3 -0
  27. data/lib/action_view/helpers/prototype_helper.rb +33 -17
  28. data/test/activerecord/pagination_test.rb +9 -0
  29. data/test/controller/addresses_render_test.rb +4 -1
  30. data/test/controller/base_test.rb +1 -1
  31. data/test/controller/caching_test.rb +3 -2
  32. data/test/controller/cookie_test.rb +11 -0
  33. data/test/controller/deprecation/deprecated_base_methods_test.rb +18 -0
  34. data/test/controller/filter_params_test.rb +1 -0
  35. data/test/controller/filters_test.rb +149 -26
  36. data/test/controller/integration_test.rb +93 -8
  37. data/test/controller/resources_test.rb +215 -36
  38. data/test/controller/routing_test.rb +1 -1
  39. data/test/controller/test_test.rb +16 -0
  40. data/test/controller/url_rewriter_test.rb +13 -1
  41. data/test/controller/verification_test.rb +15 -0
  42. data/test/fixtures/test/hello_world.rxml +2 -1
  43. data/test/template/asset_tag_helper_test.rb +5 -0
  44. data/test/template/compiled_templates_test.rb +29 -17
  45. data/test/template/number_helper_test.rb +1 -1
  46. data/test/template/prototype_helper_test.rb +2 -2
  47. metadata +84 -83
@@ -67,7 +67,7 @@ module ActionController
67
67
  @https = false
68
68
  @cookies = {}
69
69
  @controller = @request = @response = nil
70
-
70
+
71
71
  self.host = "www.example.com"
72
72
  self.remote_addr = "127.0.0.1"
73
73
  self.accept = "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"
@@ -89,7 +89,7 @@ module ActionController
89
89
  # session.https!
90
90
  # session.https!(false)
91
91
  def https!(flag=true)
92
- @https = flag
92
+ @https = flag
93
93
  end
94
94
 
95
95
  # Return +true+ if the session is mimicing a secure HTTPS request.
@@ -143,10 +143,10 @@ module ActionController
143
143
  # Performs a GET request with the given parameters. The parameters may
144
144
  # be +nil+, a Hash, or a string that is appropriately encoded
145
145
  # (application/x-www-form-urlencoded or multipart/form-data). The headers
146
- # should be a hash. The keys will automatically be upcased, with the
146
+ # should be a hash. The keys will automatically be upcased, with the
147
147
  # prefix 'HTTP_' added if needed.
148
148
  #
149
- # You can also perform POST, PUT, DELETE, and HEAD requests with #post,
149
+ # You can also perform POST, PUT, DELETE, and HEAD requests with #post,
150
150
  # #put, #delete, and #head.
151
151
  def get(path, parameters=nil, headers=nil)
152
152
  process :get, path, parameters, headers
@@ -161,31 +161,41 @@ module ActionController
161
161
  def put(path, parameters=nil, headers=nil)
162
162
  process :put, path, parameters, headers
163
163
  end
164
-
164
+
165
165
  # Performs a DELETE request with the given parameters. See get() for more details.
166
166
  def delete(path, parameters=nil, headers=nil)
167
167
  process :delete, path, parameters, headers
168
168
  end
169
-
169
+
170
170
  # Performs a HEAD request with the given parameters. See get() for more details.
171
171
  def head(path, parameters=nil, headers=nil)
172
172
  process :head, path, parameters, headers
173
173
  end
174
174
 
175
- # Performs an XMLHttpRequest request with the given parameters, mimicing
176
- # the request environment created by the Prototype library. The parameters
177
- # may be +nil+, a Hash, or a string that is appropriately encoded
178
- # (application/x-www-form-urlencoded or multipart/form-data). The headers
179
- # should be a hash. The keys will automatically be upcased, with the
180
- # prefix 'HTTP_' added if needed.
181
- def xml_http_request(path, parameters=nil, headers=nil)
182
- headers = (headers || {}).merge(
183
- "X-Requested-With" => "XMLHttpRequest",
184
- "Accept" => "text/javascript, text/html, application/xml, text/xml, */*"
185
- )
175
+ # Performs an XMLHttpRequest request with the given parameters, mirroring
176
+ # a request from the Prototype library.
177
+ #
178
+ # The request_method is :get, :post, :put, :delete or :head; the
179
+ # parameters are +nil+, a hash, or a url-encoded or multipart string;
180
+ # the headers are a hash. Keys are automatically upcased and prefixed
181
+ # with 'HTTP_' if not already.
182
+ #
183
+ # This method used to omit the request_method parameter, assuming it
184
+ # was :post. This was deprecated in Rails 1.2.4. Always pass the request
185
+ # method as the first argument.
186
+ def xml_http_request(request_method, path, parameters = nil, headers = nil)
187
+ unless request_method.is_a?(Symbol)
188
+ ActiveSupport::Deprecation.warn 'xml_http_request now takes the request_method (:get, :post, etc.) as the first argument. It used to assume :post, so add the :post argument to your existing method calls to silence this warning.'
189
+ request_method, path, parameters, headers = :post, request_method, path, parameters
190
+ end
191
+
192
+ headers ||= {}
193
+ headers['X-Requested-With'] = 'XMLHttpRequest'
194
+ headers['Accept'] = 'text/javascript, text/html, application/xml, text/xml, */*'
186
195
 
187
- post(path, parameters, headers)
196
+ process(request_method, path, parameters, headers)
188
197
  end
198
+ alias xhr :xml_http_request
189
199
 
190
200
  # Returns the URL for the given options, according to the rules specified
191
201
  # in the application's routes.
@@ -292,7 +302,7 @@ module ActionController
292
302
  @status = @status.to_i
293
303
  end
294
304
 
295
- # Encode the cookies hash in a format suitable for passing to a
305
+ # Encode the cookies hash in a format suitable for passing to a
296
306
  # request.
297
307
  def encode_cookies
298
308
  cookies.inject("") do |string, (name, value)|
@@ -450,7 +460,7 @@ module ActionController
450
460
  # without any test methods.
451
461
  def run(*args) #:nodoc:
452
462
  return if @method_name == "default_test"
453
- super
463
+ super
454
464
  end
455
465
 
456
466
  # Because of how use_instantiated_fixtures and use_transactional_fixtures
@@ -490,7 +500,7 @@ module ActionController
490
500
  @integration_session = open_session
491
501
  end
492
502
 
493
- %w(get post cookies assigns xml_http_request).each do |method|
503
+ %w(get post put head delete cookies assigns xml_http_request).each do |method|
494
504
  define_method(method) do |*args|
495
505
  reset! unless @integration_session
496
506
  # reset the html_document variable, but only for new get/post calls
@@ -1,7 +1,9 @@
1
1
  module ActionController
2
2
  # === Action Pack pagination for Active Record collections
3
3
  #
4
- # DEPRECATION WARNING: Pagination will be separated into its own plugin with Rails 2.0.
4
+ # DEPRECATION WARNING: Pagination will be moved to a plugin in Rails 2.0.
5
+ # Install the classic_pagination plugin for forward compatibility:
6
+ # script/plugin install svn://errtheblog.com/svn/plugins/classic_pagination
5
7
  #
6
8
  # The Pagination module aids in the process of paging large collections of
7
9
  # Active Record objects. It offers macro-style automatic fetching of your
@@ -130,6 +132,8 @@ module ActionController
130
132
  paginator_and_collection_for(collection_id, options)
131
133
  end
132
134
 
135
+ deprecate :paginate => 'Pagination is moving to a plugin in Rails 2.0: script/plugin install svn://errtheblog.com/svn/plugins/classic_pagination'
136
+
133
137
  # These methods become class methods on any controller
134
138
  module ClassMethods
135
139
  # Creates a +before_filter+ which automatically paginates an Active
@@ -148,6 +152,8 @@ module ActionController
148
152
  OPTIONS[self][collection_id] = options
149
153
  end
150
154
  end
155
+
156
+ deprecate :paginate => 'Pagination is moving to a plugin in Rails 2.0: script/plugin install svn://errtheblog.com/svn/plugins/classic_pagination'
151
157
  end
152
158
 
153
159
  def create_paginators_and_retrieve_collections #:nodoc:
@@ -2,48 +2,68 @@ module ActionController
2
2
  module Resources
3
3
  class Resource #:nodoc:
4
4
  attr_reader :collection_methods, :member_methods, :new_methods
5
- attr_reader :path_prefix, :name_prefix
5
+ attr_reader :path_prefix, :new_name_prefix
6
6
  attr_reader :plural, :singular
7
7
  attr_reader :options
8
8
 
9
9
  def initialize(entities, options)
10
10
  @plural = entities
11
11
  @singular = options[:singular] || plural.to_s.singularize
12
-
12
+
13
13
  @options = options
14
14
 
15
15
  arrange_actions
16
16
  add_default_actions
17
17
  set_prefixes
18
18
  end
19
-
19
+
20
20
  def controller
21
21
  @controller ||= (options[:controller] || plural).to_s
22
22
  end
23
-
23
+
24
24
  def path
25
25
  @path ||= "#{path_prefix}/#{plural}"
26
26
  end
27
-
27
+
28
28
  def new_path
29
29
  @new_path ||= "#{path}/new"
30
30
  end
31
-
31
+
32
32
  def member_path
33
33
  @member_path ||= "#{path}/:id"
34
34
  end
35
-
35
+
36
36
  def nesting_path_prefix
37
37
  @nesting_path_prefix ||= "#{path}/:#{singular}_id"
38
38
  end
39
-
39
+
40
+ def deprecate_name_prefix?
41
+ @name_prefix.blank? && !@new_name_prefix.blank?
42
+ end
43
+
44
+ def name_prefix
45
+ deprecate_name_prefix? ? @new_name_prefix : @name_prefix
46
+ end
47
+
48
+ def old_name_prefix
49
+ @name_prefix
50
+ end
51
+
52
+ def nesting_name_prefix
53
+ "#{new_name_prefix}#{singular}_"
54
+ end
55
+
56
+ def action_separator
57
+ @action_separator ||= Base.resource_action_separator
58
+ end
59
+
40
60
  protected
41
61
  def arrange_actions
42
62
  @collection_methods = arrange_actions_by_methods(options.delete(:collection))
43
63
  @member_methods = arrange_actions_by_methods(options.delete(:member))
44
64
  @new_methods = arrange_actions_by_methods(options.delete(:new))
45
65
  end
46
-
66
+
47
67
  def add_default_actions
48
68
  add_default_action(member_methods, :get, :edit)
49
69
  add_default_action(new_methods, :get, :new)
@@ -52,6 +72,7 @@ module ActionController
52
72
  def set_prefixes
53
73
  @path_prefix = options.delete(:path_prefix)
54
74
  @name_prefix = options.delete(:name_prefix)
75
+ @new_name_prefix = options.delete(:new_name_prefix)
55
76
  end
56
77
 
57
78
  def arrange_actions_by_methods(actions)
@@ -60,7 +81,7 @@ module ActionController
60
81
  flipped_hash
61
82
  end
62
83
  end
63
-
84
+
64
85
  def add_default_action(collection, method, action)
65
86
  (collection[method] ||= []).unshift(action)
66
87
  end
@@ -178,11 +199,11 @@ module ActionController
178
199
  #
179
200
  # The comment resources work the same, but must now include a value for :article_id.
180
201
  #
181
- # comments_url(@article)
182
- # comment_url(@article, @comment)
202
+ # article_comments_url(@article)
203
+ # article_comment_url(@article, @comment)
183
204
  #
184
- # comments_url(:article_id => @article)
185
- # comment_url(:article_id => @article, :id => @comment)
205
+ # article_comments_url(:article_id => @article)
206
+ # article_comment_url(:article_id => @article, :id => @comment)
186
207
  #
187
208
  # * <tt>:name_prefix</tt> -- define a prefix for all generated routes, usually ending in an underscore.
188
209
  # Use this if you have named routes that may clash.
@@ -192,7 +213,7 @@ module ActionController
192
213
  #
193
214
  # * <tt>:collection</tt> -- add named routes for other actions that operate on the collection.
194
215
  # Takes a hash of <tt>#{action} => #{method}</tt>, where method is <tt>:get</tt>/<tt>:post</tt>/<tt>:put</tt>/<tt>:delete</tt>
195
- # or <tt>:any</tt> if the method does not matter. These routes map to a URL like /messages;rss, with a route of rss_messages_url.
216
+ # or <tt>:any</tt> if the method does not matter. These routes map to a URL like /messages/rss, with a route of rss_messages_url.
196
217
  # * <tt>:member</tt> -- same as :collection, but for actions that operate on a specific member.
197
218
  # * <tt>:new</tt> -- same as :collection, but for actions that operate on the new resource action.
198
219
  #
@@ -204,19 +225,19 @@ module ActionController
204
225
  # # --> GET /thread/7/messages/1
205
226
  #
206
227
  # map.resources :messages, :collection => { :rss => :get }
207
- # # --> GET /messages;rss (maps to the #rss action)
228
+ # # --> GET /messages/rss (maps to the #rss action)
208
229
  # # also adds a named route called "rss_messages"
209
230
  #
210
231
  # map.resources :messages, :member => { :mark => :post }
211
- # # --> POST /messages/1;mark (maps to the #mark action)
232
+ # # --> POST /messages/1/mark (maps to the #mark action)
212
233
  # # also adds a named route called "mark_message"
213
234
  #
214
235
  # map.resources :messages, :new => { :preview => :post }
215
- # # --> POST /messages/new;preview (maps to the #preview action)
236
+ # # --> POST /messages/new/preview (maps to the #preview action)
216
237
  # # also adds a named route called "preview_new_message"
217
238
  #
218
239
  # map.resources :messages, :new => { :new => :any, :preview => :post }
219
- # # --> POST /messages/new;preview (maps to the #preview action)
240
+ # # --> POST /messages/new/preview (maps to the #preview action)
220
241
  # # also adds a named route called "preview_new_message"
221
242
  # # --> /messages/new can be invoked via any request method
222
243
  #
@@ -235,9 +256,10 @@ module ActionController
235
256
  # /account profile.
236
257
  #
237
258
  # See map.resources for general conventions. These are the main differences:
238
- # - a singular name is given to map.resource. The default controller name is taken from the singular name.
239
- # - To specify a custom plural name, use the :plural option. There is no :singular option
240
- # - No default index, new, or create routes are created for the singleton resource controller.
259
+ # - A singular name is given to map.resource. The default controller name is taken from the singular name.
260
+ # - There is no <tt>:collection</tt> option as there is only the singleton resource.
261
+ # - There is no <tt>:singular</tt> option as the singular name is passed to map.resource.
262
+ # - No default index route is created for the singleton resource controller.
241
263
  # - When nesting singleton resources, only the singular name is used as the path prefix (example: 'account/messages/1')
242
264
  #
243
265
  # Example:
@@ -300,7 +322,7 @@ module ActionController
300
322
  map_member_actions(map, resource)
301
323
 
302
324
  if block_given?
303
- with_options(:path_prefix => resource.nesting_path_prefix, &block)
325
+ with_options(:path_prefix => resource.nesting_path_prefix, :new_name_prefix => resource.nesting_name_prefix, &block)
304
326
  end
305
327
  end
306
328
  end
@@ -315,7 +337,7 @@ module ActionController
315
337
  map_member_actions(map, resource)
316
338
 
317
339
  if block_given?
318
- with_options(:path_prefix => resource.nesting_path_prefix, &block)
340
+ with_options(:path_prefix => resource.nesting_path_prefix, :new_name_prefix => resource.nesting_name_prefix, &block)
319
341
  end
320
342
  end
321
343
  end
@@ -324,8 +346,21 @@ module ActionController
324
346
  resource.collection_methods.each do |method, actions|
325
347
  actions.each do |action|
326
348
  action_options = action_options_for(action, resource, method)
327
- map.named_route("#{resource.name_prefix}#{action}_#{resource.plural}", "#{resource.path};#{action}", action_options)
328
- map.named_route("formatted_#{resource.name_prefix}#{action}_#{resource.plural}", "#{resource.path}.:format;#{action}", action_options)
349
+
350
+ unless resource.old_name_prefix.blank?
351
+ map.deprecated_named_route("#{action}_#{resource.name_prefix}#{resource.plural}", "#{resource.old_name_prefix}#{action}_#{resource.plural}")
352
+ map.deprecated_named_route("formatted_#{action}_#{resource.name_prefix}#{resource.plural}", "formatted_#{resource.old_name_prefix}#{action}_#{resource.plural}")
353
+ end
354
+
355
+ if resource.deprecate_name_prefix?
356
+ map.deprecated_named_route("#{action}_#{resource.name_prefix}#{resource.plural}", "#{action}_#{resource.plural}")
357
+ map.deprecated_named_route("formatted_#{action}_#{resource.name_prefix}#{resource.plural}", "formatted_#{action}_#{resource.plural}")
358
+ end
359
+
360
+ map.named_route("#{action}_#{resource.name_prefix}#{resource.plural}", "#{resource.path}#{resource.action_separator}#{action}", action_options)
361
+ map.connect("#{resource.path};#{action}", action_options)
362
+ map.connect("#{resource.path}.:format;#{action}", action_options)
363
+ map.named_route("formatted_#{action}_#{resource.name_prefix}#{resource.plural}", "#{resource.path}#{resource.action_separator}#{action}.:format", action_options)
329
364
  end
330
365
  end
331
366
  end
@@ -335,6 +370,11 @@ module ActionController
335
370
  map.named_route("#{resource.name_prefix}#{resource.plural}", resource.path, index_action_options)
336
371
  map.named_route("formatted_#{resource.name_prefix}#{resource.plural}", "#{resource.path}.:format", index_action_options)
337
372
 
373
+ if resource.deprecate_name_prefix?
374
+ map.deprecated_named_route("#{resource.name_prefix}#{resource.plural}", "#{resource.plural}")
375
+ map.deprecated_named_route("formatted_#{resource.name_prefix}#{resource.plural}", "formatted_#{resource.plural}")
376
+ end
377
+
338
378
  create_action_options = action_options_for("create", resource)
339
379
  map.connect(resource.path, create_action_options)
340
380
  map.connect("#{resource.path}.:format", create_action_options)
@@ -351,11 +391,37 @@ module ActionController
351
391
  actions.each do |action|
352
392
  action_options = action_options_for(action, resource, method)
353
393
  if action == :new
354
- map.named_route("#{resource.name_prefix}new_#{resource.singular}", resource.new_path, action_options)
355
- map.named_route("formatted_#{resource.name_prefix}new_#{resource.singular}", "#{resource.new_path}.:format", action_options)
394
+
395
+ unless resource.old_name_prefix.blank?
396
+ map.deprecated_named_route("new_#{resource.name_prefix}#{resource.singular}", "#{resource.old_name_prefix}new_#{resource.singular}")
397
+ map.deprecated_named_route("formatted_new_#{resource.name_prefix}#{resource.singular}", "formatted_#{resource.old_name_prefix}new_#{resource.singular}")
398
+ end
399
+
400
+ if resource.deprecate_name_prefix?
401
+ map.deprecated_named_route("new_#{resource.name_prefix}#{resource.singular}", "new_#{resource.singular}")
402
+ map.deprecated_named_route("formatted_new_#{resource.name_prefix}#{resource.singular}", "formatted_new_#{resource.singular}")
403
+ end
404
+
405
+ map.named_route("new_#{resource.name_prefix}#{resource.singular}", resource.new_path, action_options)
406
+ map.named_route("formatted_new_#{resource.name_prefix}#{resource.singular}", "#{resource.new_path}.:format", action_options)
407
+
356
408
  else
357
- map.named_route("#{resource.name_prefix}#{action}_new_#{resource.singular}", "#{resource.new_path};#{action}", action_options)
358
- map.named_route("formatted_#{resource.name_prefix}#{action}_new_#{resource.singular}", "#{resource.new_path}.:format;#{action}", action_options)
409
+
410
+ unless resource.old_name_prefix.blank?
411
+ map.deprecated_named_route("#{action}_new_#{resource.name_prefix}#{resource.singular}", "#{resource.old_name_prefix}#{action}_new_#{resource.singular}")
412
+ map.deprecated_named_route("formatted_#{action}_new_#{resource.name_prefix}#{resource.singular}", "formatted_#{resource.old_name_prefix}#{action}_new_#{resource.singular}")
413
+ end
414
+
415
+ if resource.deprecate_name_prefix?
416
+ map.deprecated_named_route("#{action}_new_#{resource.name_prefix}#{resource.singular}", "#{action}_new_#{resource.singular}")
417
+ map.deprecated_named_route("formatted_#{action}_new_#{resource.name_prefix}#{resource.singular}", "formatted_#{action}_new_#{resource.singular}")
418
+ end
419
+
420
+ map.named_route("#{action}_new_#{resource.name_prefix}#{resource.singular}", "#{resource.new_path}#{resource.action_separator}#{action}", action_options)
421
+ map.connect("#{resource.new_path};#{action}", action_options)
422
+ map.connect("#{resource.new_path}.:format;#{action}", action_options)
423
+ map.named_route("formatted_#{action}_new_#{resource.name_prefix}#{resource.singular}", "#{resource.new_path}#{resource.action_separator}#{action}.:format", action_options)
424
+
359
425
  end
360
426
  end
361
427
  end
@@ -365,8 +431,22 @@ module ActionController
365
431
  resource.member_methods.each do |method, actions|
366
432
  actions.each do |action|
367
433
  action_options = action_options_for(action, resource, method)
368
- map.named_route("#{resource.name_prefix}#{action}_#{resource.singular}", "#{resource.member_path};#{action}", action_options)
369
- map.named_route("formatted_#{resource.name_prefix}#{action}_#{resource.singular}", "#{resource.member_path}.:format;#{action}",action_options)
434
+
435
+ unless resource.old_name_prefix.blank?
436
+ map.deprecated_named_route("#{action}_#{resource.name_prefix}#{resource.singular}", "#{resource.old_name_prefix}#{action}_#{resource.singular}")
437
+ map.deprecated_named_route("formatted_#{action}_#{resource.name_prefix}#{resource.singular}", "formatted_#{resource.old_name_prefix}#{action}_#{resource.singular}")
438
+ end
439
+
440
+ if resource.deprecate_name_prefix?
441
+ map.deprecated_named_route("#{action}_#{resource.name_prefix}#{resource.singular}", "#{action}_#{resource.singular}")
442
+ map.deprecated_named_route("formatted_#{action}_#{resource.name_prefix}#{resource.singular}", "formatted_#{action}_#{resource.singular}")
443
+ end
444
+
445
+ map.named_route("#{action}_#{resource.name_prefix}#{resource.singular}", "#{resource.member_path}#{resource.action_separator}#{action}", action_options)
446
+ map.connect("#{resource.member_path};#{action}", action_options)
447
+ map.connect("#{resource.member_path}.:format;#{action}", action_options)
448
+ map.named_route("formatted_#{action}_#{resource.name_prefix}#{resource.singular}", "#{resource.member_path}#{resource.action_separator}#{action}.:format", action_options)
449
+
370
450
  end
371
451
  end
372
452
 
@@ -374,6 +454,11 @@ module ActionController
374
454
  map.named_route("#{resource.name_prefix}#{resource.singular}", resource.member_path, show_action_options)
375
455
  map.named_route("formatted_#{resource.name_prefix}#{resource.singular}", "#{resource.member_path}.:format", show_action_options)
376
456
 
457
+ if resource.deprecate_name_prefix?
458
+ map.deprecated_named_route("#{resource.name_prefix}#{resource.singular}", "#{resource.singular}")
459
+ map.deprecated_named_route("formatted_#{resource.name_prefix}#{resource.singular}", "formatted_#{resource.singular}")
460
+ end
461
+
377
462
  update_action_options = action_options_for("update", resource)
378
463
  map.connect(resource.member_path, update_action_options)
379
464
  map.connect("#{resource.member_path}.:format", update_action_options)
@@ -989,6 +989,10 @@ module ActionController
989
989
  def named_route(name, path, options = {})
990
990
  @set.add_named_route(name, path, options)
991
991
  end
992
+
993
+ def deprecated_named_route(name, deprecated_name, options = {})
994
+ @set.add_deprecated_named_route(name, deprecated_name)
995
+ end
992
996
 
993
997
  # Added deprecation notice for anyone who already added a named route called "root".
994
998
  # It'll be used as a shortcut for map.connect '' in Rails 2.0.
@@ -1019,7 +1023,7 @@ module ActionController
1019
1023
  def clear!
1020
1024
  @routes = {}
1021
1025
  @helpers = []
1022
-
1026
+
1023
1027
  @module ||= Module.new
1024
1028
  @module.instance_methods.each do |selector|
1025
1029
  @module.send :remove_method, selector
@@ -1055,6 +1059,38 @@ module ActionController
1055
1059
  def install(destinations = [ActionController::Base, ActionView::Base])
1056
1060
  Array(destinations).each { |dest| dest.send :include, @module }
1057
1061
  end
1062
+
1063
+ def define_deprecated_named_route_methods(name, deprecated_name)
1064
+
1065
+ [:url, :path].each do |kind|
1066
+ @module.send :module_eval, <<-end_eval # We use module_eval to avoid leaks
1067
+
1068
+ def #{url_helper_name(deprecated_name, kind)}(*args)
1069
+
1070
+ ActiveSupport::Deprecation.warn(
1071
+ 'The named route "#{url_helper_name(deprecated_name, kind)}" uses a format that has been deprecated. ' +
1072
+ 'You should use "#{url_helper_name(name, kind)}" instead.', caller
1073
+ )
1074
+
1075
+ send :#{url_helper_name(name, kind)}, *args
1076
+
1077
+ end
1078
+
1079
+ def #{hash_access_name(deprecated_name, kind)}(*args)
1080
+
1081
+ ActiveSupport::Deprecation.warn(
1082
+ 'The named route "#{hash_access_name(deprecated_name, kind)}" uses a format that has been deprecated. ' +
1083
+ 'You should use "#{hash_access_name(name, kind)}" instead.', caller
1084
+ )
1085
+
1086
+ send :#{hash_access_name(name, kind)}, *args
1087
+
1088
+ end
1089
+
1090
+ end_eval
1091
+ end
1092
+
1093
+ end
1058
1094
 
1059
1095
  private
1060
1096
  def url_helper_name(name, kind = :url)
@@ -1177,6 +1213,10 @@ module ActionController
1177
1213
  def add_named_route(name, path, options = {})
1178
1214
  named_routes[name] = add_route(path, options)
1179
1215
  end
1216
+
1217
+ def add_deprecated_named_route(name, deprecated_name)
1218
+ named_routes.define_deprecated_named_route_methods(name, deprecated_name)
1219
+ end
1180
1220
 
1181
1221
  def options_as_params(options)
1182
1222
  # If an explicit :controller was given, always make :action explicit