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

Ticket #4698 (closed enhancement: invalid)

Opened 3 years ago

Last modified 2 years ago

[PATCH] render_component handles :id in :params again

Reported by: fxn@hashref.com Assigned to: David
Priority: normal Milestone:
Component: ActionPack Version: edge
Severity: normal Keywords: render_component, id, params
Cc:

Description

After r3563, if you pass an :id key via the :params hash the controller receives :id as nil. See for instance this log:

Start rendering component ({:params=>{:center_id=>10, :id=>25}, :action=>"supervisory_commissions_widget"}):

Processing EmployeeController#supervisory_commissions_widget (for 127.0.0.1 at 2006-04-10 22:07:27) [GET]
  Session ID: 94a1e0400481a317fcd235c1360c82ac
  Parameters: {"action"=>"supervisory_commissions_widget", "id"=>nil, "controller"=>"employee", "center_id"=>10}

This is a side-effect of a change in the way some local hashes are updated in request_for_component. The attached patch, code and test, fixes this and uses code inspired by url_for.

Attachments

render_component_handles_id_in_params.diff (2.2 kB) - added by fxn@hashref.com on 04/11/06 19:58:12.

Change History

04/11/06 19:58:12 changed by fxn@hashref.com

  • attachment render_component_handles_id_in_params.diff added.

04/17/06 16:13:51 changed by anonymous

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

10/22/06 13:57:33 changed by juni0r

  • status changed from closed to reopened.
  • type changed from defect to enhancement.
  • version set to edge.
  • resolution deleted.

Maybe someone could explain why the resolution was set to invalid. The render_component semantics seem really odd to me.

Why is it

render_component :controller => "far", :action => "boo", :params => {:some => "thing"}

but

url_for :controller => "far", :action => "boo", :some => "thing"

And it gets really funny with the :id parameter indeed. It must not be in the params hash but on the top level like :controller and :action.

Maybe there is a good reason for this perceived inconsistency. Wouldn't it make sense to deprecate the current semantics in favor of those of url_for?

02/19/07 00:38:55 changed by josh

  • status changed from reopened to closed.
  • resolution set to invalid.

Components have been deprecated and will be completely removed by Rails 2.0