ybernet-uAjRD0nVeow@public.gmane.org
2008-Nov-12 23:07 UTC
Controller method/action being called twice (once POST and once GET) for file upload - why?
I''m uploading a file via the user''s browser. The index method in my controller is: <%= form_tag({:action=>''receive_file''}, :multipart => true)%> <input type="file" name="user_data_file" /> <p></p> <input type="submit" value="Upload" /> </form> I get a form with a ''browse'' button and an ''upload'' button. I use the browse control to select a file and I press the ''upload'' button. The method ''receive_file'' in my controller gets called (with method GET) and executes, then passes control to the corresponding view so far so good. The strange thing is that behind the scenes, something immediately calls my ''receive_file'' method a second time (this time with method POST). Why is this hapenning? How am I supposed to handle it? I don''t want to execute my receive_file method twice. Thanks for your help, Yoram --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
ybernet-uAjRD0nVeow@public.gmane.org
2008-Nov-13 01:00 UTC
Re: Controller method/action being called twice (once POST and once GET) for file upload - why? - in fact, multiple controller methods are being called twice...
per the subject line, further investigation reveals that all the methods in my controller that i am using, are called exactly twice each time i expect them to be called once. i am confused... On Nov 12, 3:07 pm, "yber...-uAjRD0nVeow@public.gmane.org" <yber...-uAjRD0nVeow@public.gmane.org> wrote:> I''m uploading a file via the user''s browser. The index method in my > controller is: > > <%= form_tag({:action=>''receive_file''}, :multipart => true)%> > <input type="file" name="user_data_file" /> > <p></p> > <input type="submit" value="Upload" /> > </form> > > I get a form with a ''browse'' button and an ''upload'' button. I use the > browse control to select a file and I press the ''upload'' button. > > The method ''receive_file'' in my controller gets called (with method > GET) and executes, then passes control to the corresponding view so > far so good. > > The strange thing is that behind the scenes, something immediately > calls my ''receive_file'' method a second time (this time with method > POST). > > Why is this hapenning? How am I supposed to handle it? I don''t want to > execute my receive_file method twice. > > Thanks for your help, > Yoram--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Nov-13 01:48 UTC
Re: Controller method/action being called twice (once POST and once GET) for file upload - why? - in fact, multiple controller methods are being called twice...
On Nov 13, 1:00 am, "yber...-uAjRD0nVeow@public.gmane.org" <yber...-uAjRD0nVeow@public.gmane.org> wrote:> per the subject line, further investigation reveals that all the > methods in my controller that i am using, are called exactly twice > each time i expect them to be called once. i am confused...Anything interesting in your controller? Can you see (using tcpdump or whatever your platform has) whether the browser is actually making two requests ? Fred> > On Nov 12, 3:07 pm, "yber...-uAjRD0nVeow@public.gmane.org" <yber...-uAjRD0nVeow@public.gmane.org> wrote: > > > I''m uploading a file via the user''s browser. The index method in my > > controller is: > > > <%= form_tag({:action=>''receive_file''}, :multipart => true)%> > > <input type="file" name="user_data_file" /> > > <p></p> > > <input type="submit" value="Upload" /> > > </form> > > > I get a form with a ''browse'' button and an ''upload'' button. I use the > > browse control to select a file and I press the ''upload'' button. > > > The method ''receive_file'' in my controller gets called (with method > > GET) and executes, then passes control to the corresponding view so > > far so good. > > > The strange thing is that behind the scenes, something immediately > > calls my ''receive_file'' method a second time (this time with method > > POST). > > > Why is this hapenning? How am I supposed to handle it? I don''t want to > > execute my receive_file method twice. > > > Thanks for your help, > > Yoram--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
ybernet-uAjRD0nVeow@public.gmane.org
2008-Nov-13 02:08 UTC
Re: Controller method/action being called twice (once POST and once GET) for file upload - why? - in fact, multiple controller methods are being called twice...
Fred, thanks: Well - per your suggestion, I turned net tracking on in firebug (I''m using firefox). And the problem went away... like Heisenberg said :-). Sorry for bothering the list with such artifact. It''s a little scary to see the browser get in to such a state though... Y On Nov 12, 5:48 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Nov 13, 1:00 am, "yber...-uAjRD0nVeow@public.gmane.org" <yber...-uAjRD0nVeow@public.gmane.org> wrote: > > > per the subject line, further investigation reveals that all the > > methods in my controller that i am using, are called exactly twice > > each time i expect them to be called once. i am confused... > > Anything interesting in your controller? Can you see (using tcpdump or > whatever your platform has) whether the browser is actually making two > requests ? > > Fred > > > > > > > On Nov 12, 3:07 pm, "yber...-uAjRD0nVeow@public.gmane.org" <yber...-uAjRD0nVeow@public.gmane.org> wrote: > > > > I''m uploading a file via the user''s browser. The index method in my > > > controller is: > > > > <%= form_tag({:action=>''receive_file''}, :multipart => true)%> > > > <input type="file" name="user_data_file" /> > > > <p></p> > > > <input type="submit" value="Upload" /> > > > </form> > > > > I get a form with a ''browse'' button and an ''upload'' button. I use the > > > browse control to select a file and I press the ''upload'' button. > > > > The method ''receive_file'' in my controller gets called (with method > > > GET) and executes, then passes control to the corresponding view so > > > far so good. > > > > The strange thing is that behind the scenes, something immediately > > > calls my ''receive_file'' method a second time (this time with method > > > POST). > > > > Why is this hapenning? How am I supposed to handle it? I don''t want to > > > execute my receive_file method twice. > > > > Thanks for your help, > > > Yoram- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---