Issue with params.merge

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

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.

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.