问题
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:
You can define your method in controller as helper method:
helper_method :send_file
来源:https://stackoverflow.com/questions/27418340/helper-methods-actionview-and-actioncontroller