开发者

rails create a button for downloading

I need to create a button for downloading So far I have create a button using this

<%= form_tag '/myproject/download', :multipart => true, :onclick=>"document.getElementById('popup').style.display='block'; return true;" %>

<%= submit_tag 'Download'%> <% end %>

but I don"t know how to link the submit_tag with the link of downloading. (so as simple as if I press the butt开发者_StackOverflowon, then it will go to localhost/file and pop up a save to option) I am aware that I can use link_to, but I need to put a button that acts as a link_to

Can anyone point out how to do this in rails? thank you


Try button_to method, which is nearly identical to link_to

http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-button_to


You can put a link_to and then style it like a button. Or you can do something like this Is there a way with rails form helper to produce a button tag for submit


Try to use the button_to method. You can take a look to the docs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜