# Has render\_component changed?

**URL:** <https://www.ruby-forum.com/t/has-render-component-changed/57431>\
**Category:** Rails\
**Created:** [April 10, 2006, 10:18pm UTC](https://www.ruby-forum.com/t/has-render-component-changed/57431 "2006-04-10T22:18:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fxn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/77aa72/32.png) [@fxn](https://www.ruby-forum.com/u/fxn)\
**Post date:** [April 10, 2006, 10:18pm UTC](https://www.ruby-forum.com/t/has-render-component-changed/57431/1 "2006-04-10T22:18:03Z")

</div>

I have an application that worked fine, but after the recent updates  
has broken in some calls to render\_component from views. I might be  
missing something but as far as I remember Rails updates is the only  
thing I’ve done in between. See the log:

\*\*\* START LOG SNIPPET

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}

\*\*\* END LOG SNIPPET

The “id” goes from 25 in the view to nil in the controller. Does  
anybody know why?

– fxn

PS: I should have frozen rails there.

---

<div class="post-metadata">

**Author:** ![fxn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/77aa72/32.png) [@fxn](https://www.ruby-forum.com/u/fxn)\
**Post date:** [April 10, 2006, 11:07pm UTC](https://www.ruby-forum.com/t/has-render-component-changed/57431/2 "2006-04-10T23:07:03Z")

</div>

On Apr 10, 2006, at 22:15, Xavier N. wrote:

> The “id” goes from 25 in the view to nil in the controller. Does  
> anybody know why?

Indeed, I froze 1.0 under vendor and everything is working again.

I would like to understand what has changed in render\_component  
anyway if anyone knows it. My guess is that something happens with  
parameters called “id”, the rest seems to travel just fine.

– fxn

---

<div class="post-metadata">

**Author:** ![fxn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/77aa72/32.png) [@fxn](https://www.ruby-forum.com/u/fxn)\
**Post date:** [April 10, 2006, 11:16pm UTC](https://www.ruby-forum.com/t/has-render-component-changed/57431/3 "2006-04-10T23:16:19Z")

</div>

One thing I do know is that :id need not be passed inside  
:params–just pass it directly.

–

Ed Frederick - [edwardfrederick.com](http://edwardfrederick.com)

---

<div class="post-metadata">

**Author:** ![fxn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/77aa72/32.png) [@fxn](https://www.ruby-forum.com/u/fxn)\
**Post date:** [April 11, 2006, 2:10am UTC](https://www.ruby-forum.com/t/has-render-component-changed/57431/4 "2006-04-11T02:10:39Z")

</div>

Hello Xavier,

> > :action=\>“supervisory\_commissions\_widget”})
> > 
> > The “id” goes from 25 in the view to nil in the controller. Does  
> > anybody know why?
> 
> Indeed, I froze 1.0 under vendor and everything is working again.
> 
> I would like to understand what has changed in render\_component  
> anyway if anyone knows it. My guess is that something happens with  
> parameters called “id”, the rest seems to travel just fine.

Well, it seems it’s due to r3563 when bitsweat committed performances  
patches from Stefan K. :

in trunk/actionpack/lib/action\_controller/components.rb  
module method #request\_for\_component was modified,  
especially these lines, from :

(options[:params] || {}).merge({ “controller” =\> options[:controller],  
“action” =\> options[:action], “id” =\> options[:id]  
}).with\_indifferent\_access

to :

(options[:params] || {}).with\_indifferent\_access.regular\_update(  
“controller” =\> controller\_name, “action” =\> options[:action], “id”  
=\> options[:id])

In your situation, you’ve got in options hash :

:params=\> {:center\_id=\>10, :id=\>25},  
:id =\> nil

so after the merge, you’ve got this temporary hash :

{:center\_id=\>10, :id=\>25, “controller” =\>“employee”,  
:action"=\>“supervisory\_commissions\_widget”, “id” =\> nil }

since option[:id] is nil.

When a HashWithIndifferentAccess object is created from  
a Hash, if there’s collision between :foo and ‘foo’, I can’t figure  
out how it works, but in your case the (:id, 25) pair wins.

So ‘id’ =\> 25 is fine in the request.

After r3563, the HashWithIndifferentAccess object is created first  
so you’ve got :

{ ‘center\_id’ =\>10, ‘id’ =\>25 }

Then the (id, 25) pair is overwritten by (id, nil) by the  
#regular\_update  
call. so you’ve got ‘id’ =\> nil in the request.

As Edward wrote, pass :id directly and it should work.

```
-- Jean-FranÃ§ois.
```

---

<div class="post-metadata">

**Author:** ![fxn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/77aa72/32.png) [@fxn](https://www.ruby-forum.com/u/fxn)\
**Post date:** [April 11, 2006, 8:33am UTC](https://www.ruby-forum.com/t/has-render-component-changed/57431/5 "2006-04-11T08:33:53Z")

</div>

On Apr 11, 2006, at 2:08, Jean-François wrote:

> As Edward wrote, pass :id directly and it should work.

Excellent analysis. Looks like a bug then, I’ll report it.

Why is :id looked for in options in the first place? From the docs I  
would expect params to contain all parameters, nothing special is  
said about :id.

– fxn
