Or perhaps I am stumbling in newbie fashion (tho I have active_merchant
and a store site basically up and running in development mode - still I
don''t feel I always understand what is going on.)
So, when I have
send_file(filename, :type => ''application/x-zip'')
redirect :action => index
the send_file seems to hang, rather than complete. I''m deducing this
because of errors that happen after the send_file. When I try to
navigate from the page containing ''send_file'' to another page,
I get an
error with a trace indicating that it has not been able to complete the
redirect.
If the send_file is followed by a ''redirect :action =>
index''
the redirect is never executed.
If I comment out the send_file, the redirect is always executed.
What is the problem here? I''m stumped.
thanks much!
Here is the relevant portion of the trace, see the download/redirect
stuff:
er.rb:173:in `start_thread''
/usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread''
/usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start''
/usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start''
/usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start''
/usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start''
/usr/local/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:67:in
`dispatch''
/usr/local/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/servers/webrick.rb:59
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require''
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require''
/usr/local/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/server.rb:30
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require''
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require''
script/server:3</code></pre>
</div>
<div id="Full-Trace" style="display: none;">
<pre><code>/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:840:in
`redirect_to''
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:854:in
`redirect_to''
app/controllers/products_controller.rb:167:in `download_vbj_product''
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in
`perform_action_without_filters''
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
minka wrote:> So, when I have > send_file(filename, :type => ''application/x-zip'') > redirect :action => indexThis will get you into trouble. redirect is actually a reponse that just has a header that tells the browser to look in another url, and then the browser obeys. send_file is also a response that sends binary data to the browser. You cant send 2 reponses to only 1 request. So you can''t redirect and send a file in the same request. You need to find a different to do what you want here, because this code here will definately not work. -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
Alex Wayne wrote:> minka wrote: >> So, when I have >> send_file(filename, :type => ''application/x-zip'') >> redirect :action => index > > This will get you into trouble. redirect is actually a reponse that > just has a header that tells the browser to look in another url, and > then the browser obeys. send_file is also a response that sends binary > data to the browser. > > You cant send 2 reponses to only 1 request. So you can''t redirect and > send a file in the same request. You need to find a different to do > what you want here, because this code here will definately not work.in my app i use this: send_file(filename, :type => ''application/x-zip'') render :action => index -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
Getting rid of the redirect fixed it, thanks! note I couldn''t use render :action => index either, same problem there. this group is a great help. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---