module ActionController::Helpers::ClassMethods
def all_application_helpers
def all_application_helpers all_helpers_from_path(helpers_path) end
def all_helpers_from_path(path)
ActionController::Base.all_helpers_from_path 'app/helpers'
Returns a list of helper names in a given path.
def all_helpers_from_path(path) helpers = Array(path).flat_map do |_path| names = Dir["#{_path}/**/*_helper.rb"].map { |file| file[_path.to_s.size + 1..-"_helper.rb".size - 1] } names.sort! end helpers.uniq! helpers end
def helper_attr(*attrs)
==== Parameters
helper_attr :name
attr_accessor :name
controller and makes them available to the view:
following adds new +name+ and name= instance methods to a
Declares helper accessors for controller attributes. For example, the
def helper_attr(*attrs) attrs.flatten.each { |attr| helper_method(attr, "#{attr}=") } end
def helpers
using {helper}[rdoc-ref:AbstractController::Helpers::ClassMethods#helper]
This may cause incorrect behaviour with capture methods. Consider
Note that the proxy is rendered under a different view context.
Provides a proxy to access helper methods from outside the view.
def helpers @helper_proxy ||= begin proxy = ActionView::Base.empty proxy.config = config.inheritable_copy proxy.extend(_helpers) end end
def modules_for_helpers(args)
==== Returns
* args - A list of helpers
==== Parameters
all helpers in helpers_path.
Override modules_for_helpers to accept +:all+ as argument, which loads
def modules_for_helpers(args) args += all_application_helpers if args.delete(:all) super(args) end