Module: ActionController::Helpers::ClassMethods
- Defined in:
- lib/action_controller/metal/helpers.rb
Instance Method Summary collapse
-
#helper_attr(*attrs) ⇒ Object
Declares helper accessors for controller attributes.
-
#helpers ⇒ Object
Provides a proxy to access helpers methods from outside the view.
- #helpers_dir ⇒ Object
- #helpers_dir=(value) ⇒ Object
Instance Method Details
#helper_attr(*attrs) ⇒ Object
Declares helper accessors for controller attributes. For example, the following adds new name
and name=
instance methods to a controller and makes them available to the view:
helper_attr :name
attr_accessor :name
Parameters
- *attrs<Array[String, Symbol]>
-
Names of attributes to be converted
into helpers.
80 81 82 |
# File 'lib/action_controller/metal/helpers.rb', line 80 def helper_attr(*attrs) attrs.flatten.each { |attr| helper_method(attr, "#{attr}=") } end |
#helpers ⇒ Object
Provides a proxy to access helpers methods from outside the view.
85 86 87 |
# File 'lib/action_controller/metal/helpers.rb', line 85 def helpers @helper_proxy ||= ActionView::Base.new.extend(_helpers) end |
#helpers_dir ⇒ Object
61 62 63 64 |
# File 'lib/action_controller/metal/helpers.rb', line 61 def helpers_dir ActiveSupport::Deprecation.warn "helpers_dir is deprecated, use helpers_path instead", caller self.helpers_path end |
#helpers_dir=(value) ⇒ Object
66 67 68 69 |
# File 'lib/action_controller/metal/helpers.rb', line 66 def helpers_dir=(value) ActiveSupport::Deprecation.warn "helpers_dir= is deprecated, use helpers_path= instead", caller self.helpers_path = Array.wrap(value) end |