Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

catch nil.to_sym errors in partial_renderer, and raise ArgumentError …

…instead
  • Loading branch information...
commit e25e87a5433637e23b40af07ababb2dcc093a9a9 1 parent 773aad8
Tieg Zaharia tiegz authored committed
2  actionpack/lib/action_view/renderer/partial_renderer.rb
@@ -451,7 +451,7 @@ def merge_prefix_into_object_path(prefix, object_path)
451 451 end
452 452
453 453 def retrieve_variable(path)
454   - variable = @options[:as].try(:to_sym) || path[%r'_?(\w+)(\.\w+)*$', 1].to_sym
  454 + variable = @options[:as].try(:to_sym) || path[%r'_?(\w+)(\.\w+)*$', 1].try(:to_sym)
455 455 variable_counter = :"#{variable}_counter" if @collection
456 456 [variable, variable_counter]
457 457 end
9 actionpack/test/template/render_test.rb
@@ -161,6 +161,15 @@ def test_render_partial_with_invalid_name
161 161 "and is followed by any combinations of letters, numbers, or underscores.", e.message
162 162 end
163 163
  164 + def test_render_partial_with_missing_filename
  165 + @view.render(:partial => "test/")
  166 + flunk "Render did not raise ArgumentError"
  167 + rescue ArgumentError => e
  168 + assert_equal "The partial name (test/) is not a valid Ruby identifier; " +
  169 + "make sure your partial name starts with a letter or underscore, " +
  170 + "and is followed by any combinations of letters, numbers, or underscores.", e.message
  171 + end
  172 +
164 173 def test_render_partial_with_incompatible_object
165 174 @view.render(:partial => nil)
166 175 flunk "Render did not raise ArgumentError"

0 comments on commit e25e87a

Please sign in to comment.
Something went wrong with that request. Please try again.