Reputation: 49
I think i have got a very special question: "How can I Download a file from an rails app...?" This question is asked a few times but every solution does not work for my problem. So i need a good railer for that ;-) or 2 more eyes...
In my controller i got a helper method:
def download_file
send_data "#{Rails.root}/public/files/sample.txt"
end
helper_method :download_file
In my view i called this method:
<%= link_to 'Download File', :action => :download_files %>
But i got an
No route matches {:action=>"download_files", ...}
error
I tried to link it directly to my public folder file but it doesnt work
Can you may help me?
Upvotes: 0
Views: 154
Reputation: 11116
Thats because no route matches action download_files, I hope that clears it ! Add route
get "download_files", :to => "controller#action"
or if your controller is named foo
.
resources :foo do
get 'download_files' , :on => :collection
end
Upvotes: 1