Module: SelectableAttrRails::Helpers::SelectHelper::FormBuilder
- Defined in:
- lib/selectable_attr_rails/helpers/select_helper.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#select_with_attr_enumeable(method, *args, &block) ⇒ Object
def select_with_attr_enumeable(method, choices, options = {}, html_options = {}, &block).
Class Method Details
.included(base) ⇒ Object
56 57 58 59 60 |
# File 'lib/selectable_attr_rails/helpers/select_helper.rb', line 56 def self.included(base) base.module_eval do alias_method_chain :select, :attr_enumeable end end |
Instance Method Details
#select_with_attr_enumeable(method, *args, &block) ⇒ Object
def select_with_attr_enumeable(method, choices, options = {}, html_options = {}, &block)
63 64 65 66 67 68 69 |
# File 'lib/selectable_attr_rails/helpers/select_helper.rb', line 63 def select_with_attr_enumeable(method, *args, &block) = args.first.is_a?(Array) ? (args[1] ||= {}) : (args[0] ||= {}) object = ( || {}).delete(:object) || @object || instance_variable_get(@object_name) rescue nil .update({:object => object}) [:selected] = object.send(method) if object @template.select(@object_name, method, *args, &block) end |