I have this coupon form
<%form_for(:download,:download,:url=>{:controller=>"coupons",:action=>"verifycoupon"},:remote=>true) do |f| %>
<%=text_field :download,:code%>
<%=f.submit "verify"%>
<%end%>
and after validating the code on the controller's action i have a confirmation like:
render :update do |page|
page.alert "OK"
end
Now I want to send a file to the browser with the send_file
instruction but nothing seems to happen
send_file("/path/to/my/file.extension")
and in the log I can see
"Sent file /path/to/my/file.extension (0.1ms)"
I was wondering if there's something like
render :update do |page|
page.send_file("/path/to/my/file.extension")
end
#### Update #######
my Controller's action looks something like
def verifycoupon
code = Code.find(params[:download][:code])
if code
if code.is_active?
render :update do |page|
page.alert "ok"
end
send_file("/path/to/my/file.extension")
else
render :update do |page|
page.alert "this code has already been used"
end
end
else
render :update do |page|
page.alert "Code does't exist"
end
end
end