[英]Rails3 – How do I make a custom Helper available to controllers And Views
Given the custom helper file in app/helpers/url_helper.rb 给定app / helpers / url_helper.rb中的自定义帮助文件
module UrlHelper
...
end
How do I make it accessible in all controllers and in all views? 如何在所有控制器和所有视图中访问它?
Or... include them into your controller 或者......将它们包含在您的控制器中
class ApplicationController < ActionController::Base
include UrlHelper
end
将它放在ApplicationController(不是帮助器)中并声明helper_method :method_name
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.