Using send_file in helper
I'm开发者_StackOverflow社区 trying to use send_file
method in application_helper.rb and receiving the following error:
undefined method `send_file' for #<#<Class:0x00000003cc7ad8>:0x00000003cc4ea0>
Is there a way to get around this? I know that I can put my helper inside controller but I don't want to do that.
You can't send a file from a helper.
The send_file method is defined in ActionController::Streaming and is therefore not available in helpers. Helpers are for your code which helps with views. If you're writing a 'helper' for a controller, it shouldn't really be a helper. It should be a module in lib which you require and include in the controller.
You can't use send_file inside your helper.
Explain, why do you need to send file from your view helper and how should it work?
精彩评论