Skip to content
This repository
Browse code

More descriptive error when rendering a partial with `:layout => true`

  • Loading branch information...
commit 60b525c751a2407712d8ea1854b9b31f68a31406 1 parent 7730655
Yves Senn authored
10  actionpack/CHANGELOG.md
Source Rendered
... ...
@@ -1,5 +1,15 @@
1 1
 ## Rails 4.0.0 (unreleased) ##
2 2
 
  3
+*   More descriptive error messages when calling `render :partial` with
  4
+    an invalid `:layout` argument.
  5
+    #8376
  6
+
  7
+        render :partial => 'partial', :layout => true
  8
+
  9
+        # results in ActionView::MissingTemplate: Missing partial /true
  10
+
  11
+    *Yves Senn*
  12
+
3 13
 *   Sweepers was extracted from Action Controller as `rails-observers` gem.
4 14
 
5 15
     *Rafael Mendonça França*
2  actionpack/lib/action_view/renderer/partial_renderer.rb
@@ -293,7 +293,7 @@ def render_partial
293 293
       object, as = @object, @variable
294 294
 
295 295
       if !block && (layout = @options[:layout])
296  
-        layout = find_template(layout, @template_keys)
  296
+        layout = find_template(layout.to_s, @template_keys)
297 297
       end
298 298
 
299 299
       object ||= locals[as]
5  actionpack/test/template/render_test.rb
@@ -437,6 +437,11 @@ def test_render_layout_with_a_nested_render_layout_call_using_block_with_render_
437 437
       @view.render(:partial => 'test/partial_with_layout_block_content', :layout => 'test/layout_for_partial', :locals => { :name => 'Foo!'})
438 438
   end
439 439
 
  440
+  def test_render_partial_with_layout_raises_descriptive_error
  441
+    e = assert_raises(ActionView::MissingTemplate) { @view.render(partial: 'test/partial', layout: true) }
  442
+    assert_match "Missing partial /true with", e.message
  443
+  end
  444
+
440 445
   def test_render_with_nested_layout
441 446
     assert_equal %(<title>title</title>\n\n<div id="column">column</div>\n<div id="content">content</div>\n),
442 447
       @view.render(:file => "test/nested_layout", :layout => "layouts/yield")

0 notes on commit 60b525c

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