# Issue with params.merge

**URL:** <https://www.ruby-forum.com/t/issue-with-params-merge/120916>\
**Category:** Rails\
**Created:** [November 21, 2007, 7:22pm UTC](https://www.ruby-forum.com/t/issue-with-params-merge/120916 "2007-11-21T19:22:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![d2kagw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b5a626/32.png) [@d2kagw](https://www.ruby-forum.com/u/d2kagw)\
**Post date:** [November 21, 2007, 7:22pm UTC](https://www.ruby-forum.com/t/issue-with-params-merge/120916/1 "2007-11-21T19:22:16Z")

</div>

This is going to be difficult to explain so please let me know if  
further elaboration is needed.

I have a button that does a remote call as such (from ‘list.rhtml’):

\<%  
params[:old\_meetings] ||= ‘hide’  
%\>

\<% if params[:old\_meetings] == ‘hide’ %\>  
\<%= button\_remote(‘blue’, ‘Show Old’, {:url =\>  
params.merge({:old\_meetings =\> ‘show’}), :update =\> ‘os\_content’}) %\>  
\<% else %\>  
\<%= button\_remote(‘blue’, ‘Hide Old’, {:url =\>  
params.merge({:old\_meetings =\> ‘hide’}), :update =\> ‘os\_content’}) %\>  
\<% end %\>

As you can tell, its purpose is to show or hide old meetings. The  
issue I’m having is that when I create a new meeting, it redirects me  
to the ‘list’ page, and for every time I hit the ‘show / hide’ button  
it creates a duplicate of the new meeting.

I don’t fully understand how the params.merge call works, and I’m  
hoping someone can break it down for me so I can stop this duplication  
from happening.

Thanks,

-Aaron

---

<div class="post-metadata">

**Author:** ![d2kagw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b5a626/32.png) [@d2kagw](https://www.ruby-forum.com/u/d2kagw)\
**Post date:** [November 22, 2007, 4:44pm UTC](https://www.ruby-forum.com/t/issue-with-params-merge/120916/2 "2007-11-22T16:44:36Z")

</div>

Not sure what button\_remote is doing, but calling params.merge does  
not actually affect params, it gives you a copy of it. If you call  
params.merge! with a bang (!) that will affect the original params hash.

Hope that helps.

–  
James M.

---

<div class="post-metadata">

**Author:** ![d2kagw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b5a626/32.png) [@d2kagw](https://www.ruby-forum.com/u/d2kagw)\
**Post date:** [November 26, 2007, 2:45am UTC](https://www.ruby-forum.com/t/issue-with-params-merge/120916/3 "2007-11-26T02:45:22Z")

</div>

that does help. button\_remote is a helper that calls link\_to\_remote.  
this would explain why it’s duplicated the newly created item. much  
obliged.
