Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #6684 (closed defect: fixed)

Opened 2 years ago

Last modified 6 months ago

[PATCH] Fix ActionController::Base handles render :text => false

Reported by: tjennings Assigned to:
Priority: normal Milestone: 2.x
Component: ActionPack Version: edge
Severity: normal Keywords: render text false verified
Cc: dave.hoover@gmail.com

Description

Calling render :text with a boolean attribute fails when the attribute has a value of false. The current in_place_edit_for implementation exposes this defect when handling a boolean attribute of a model. That code looks like this:

render :text => @item.send(attribute)

We believe this is correct and the true error resides in the render method, which incorrecty does the following:

if text = options[:text]
  render_text(options[:text], options[:status])
...

Attachments

fix_actioncontroller_base_render_text_handles_false_object.diff (1.3 kB) - added by tjennings on 11/22/06 19:37:57.
Patch to fix defect, with updated render_test.rb
fix_actioncontroller_base_render_text_handles_false_object-v2.diff (1.3 kB) - added by PotatoSalad on 12/31/07 15:39:00.
Updated version of the patch to work with rails trunk [8514]
fix_actioncontroller_base_render_text_handles_false_object.better_tests.diff (1.4 kB) - added by chuyeow on 12/31/07 15:45:31.

Change History

11/22/06 19:37:57 changed by tjennings

  • attachment fix_actioncontroller_base_render_text_handles_false_object.diff added.

Patch to fix defect, with updated render_test.rb

01/31/07 17:29:14 changed by redsquirrel

Any plan to incorporate this fix? It would be helpful to not have to override Rails render behavior in our app in order to do Ajax in-place editing of boolean attributes.

12/31/07 15:28:00 changed by chjunior

+1

of course that the text should be a string (and render :text => @item.send(attribute).to_s works), but the patch makes the code better too, so I liked.

12/31/07 15:39:00 changed by PotatoSalad

  • attachment fix_actioncontroller_base_render_text_handles_false_object-v2.diff added.

Updated version of the patch to work with rails trunk [8514]

12/31/07 15:45:31 changed by chuyeow

  • attachment fix_actioncontroller_base_render_text_handles_false_object.better_tests.diff added.

12/31/07 15:49:37 changed by chuyeow

Sorry but I think

assert_equal false, @response.body

is actually an incorrect test.

Added another test for nil as mentioned about here: http://www.jroller.com/obie/entry/render_text_gotcha

12/31/07 15:57:47 changed by chuyeow

  • owner deleted.
  • milestone set to 2.x.

-1 to the 1st 2 patches because assert_equal false, @response.body should actually fail since it doesn't satisfy the intentions behind this patch.

01/03/08 07:37:21 changed by xaviershay

+1 3rd patch, worked on r8540

01/03/08 10:19:53 changed by remvee

+1 3rd patch

01/03/08 14:07:32 changed by danger

  • keywords changed from render text false to render text false verified.

+1 3rd patch

01/06/08 20:53:00 changed by bitsweat

  • status changed from new to closed.
  • resolution set to fixed.

(In [8577]) Support render :text => nil. Closes #6684.