I have the following button to download a file.
= button_to \'download\', action: \'download\', method: \'get\'
And I have a download
In your routes.rb
:
resources :movies do
get 'download', on: :member
end
Now, in your view you need to specify, what movie you want to download:
= button_to 'download', download_movie_path(@movie), method: 'get'
Also, note:
Use path
instead of specifying controller/action
in helpers.
Use link_to
for GET
requests and if you need link with button style apply it through CSS. button_to
with GET
request is a bad practice.