Caution: Be careful with AJAX calls and redirecting! It took me a while to figure out why some customers were being emailed multiple times until I finally figured out the steps to reproduce the problem. For example - On a detail (show) form, I would click a button to email them a document. This would invoke an ajax remote call and update the UI with the status. Then, I would go and create an activity (from the show form). In the normal course of events, after an activity is created, I want to redirect back to the show form. In this case, since the email was just sent, that was the last action before the activity creation. Thus, the redirect back launched the ajax call again instead of doing what I wanted - which is showing the form. This was somewhat transparent in that the show form still came up! Just an FYI for anyone who may be experiencing anything like it. Regards, Michael -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
And the solution would be to set history.previous manually after performing your AJAX call (for those wondering). On 28/08/06, Michael Modica <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Caution: Be careful with AJAX calls and redirecting! It took me a > while to figure out why some customers were being emailed multiple times > until I finally figured out the steps to reproduce the problem. > > For example - On a detail (show) form, I would click a button to email > them a document. This would invoke an ajax remote call and update the > UI with the status. Then, I would go and create an activity (from the > show form). In the normal course of events, after an activity is > created, I want to redirect back to the show form. In this case, since > the email was just sent, that was the last action before the activity > creation. Thus, the redirect back launched the ajax call again instead > of doing what I wanted - which is showing the form. > > This was somewhat transparent in that the show form still came up! Just > an FYI for anyone who may be experiencing anything like it. > > Regards, > > Michael > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
:-) Sorry! No good to post a problem w/o a solution! If you use the session data or custom redirect logic (not necessarily assuming back button) (i.e. an application helper) then the other solution is to correct the entries, session or otherwise, in the action being called by the remote call. The point of my warning is that this is easy to forget when making an ajax call because the UI isn''t navigating away from where it was! Thanks, Michael -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---