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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 Mitchell On Nov 21, 2007, at 1:21 PM, Aaron wrote:> > 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 > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. On Nov 22, 9:43 am, Mitchell James <jmitc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Not sure what button_remote is doing, but callingparams.mergedoes > 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 Mitchell > > On Nov 21, 2007, at 1:21 PM, Aaron wrote: > > > > > 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 theparams.mergecall works, and I''m > > hoping someone can break it down for me so I can stop this duplication > > from happening. > > > Thanks, > > > -Aaron--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---