Helper methods, ActionView and ActionController

…衆ロ難τιáo~ 提交于 2020-01-16 13:22:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!