Helper methods, ActionView and ActionController

2019-09-16 12:30发布

I have a method in application_contoller.rb that includes a call to send_file. I'm calling it from a partial that's rendered by javascript, and getting the following error -

ActionView::Template::Error (undefined method `send_file' for #<#<Class:0x0...

I can kind of see what's happening - send_file is a controller method, so unavailable in the way I'm using it - my question is, how do I make it available?

1条回答
混吃等死
2楼-- · 2019-09-16 12:52

You can define your method in controller as helper method:

helper_method :send_file
查看更多
登录 后发表回答