简体   繁体   中英

Rails3 – How do I make a custom Helper available to controllers And Views

Given the custom helper file in 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM