Class: Ransack::Helpers::FormBuilder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- Ransack::Helpers::FormBuilder
- Defined in:
- lib/ransack_abbreviator/ransack_extensions/helpers/form_builder.rb
Instance Method Summary collapse
- #abbr_attribute_select(options = {}, html_options = {}) ⇒ Object
- #method_missing(method_id, *args, &block) ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_id, *args, &block) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/ransack_abbreviator/ransack_extensions/helpers/form_builder.rb', line 6 def method_missing(method_id, *args, &block) method_name = method_id.to_s if method_name.starts_with?('abbr_') raise ArgumentError, "abbreviated form helpers must be called inside a search FormBuilder!" unless object.respond_to?(:context) ransack_name = args.shift actual_method = method_name.sub('abbr_', '') abbreviated_ransack_name = object.context.encode_parameter(ransack_name) self.send(actual_method, abbreviated_ransack_name, *args, &block) else super end end |
Instance Method Details
#abbr_attribute_select(options = {}, html_options = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ransack_abbreviator/ransack_extensions/helpers/form_builder.rb', line 19 def abbr_attribute_select( = {}, = {}) raise ArgumentError, "abbr_attribute_select must be called inside a search FormBuilder!" unless object.respond_to?(:context) [:include_blank] = true unless .has_key?(:include_blank) associations = association_array([:associations]) if associations.size > 0 bases = [''] + associations grouped_collection = encoded_attribute_collection_for_bases(bases) @template.grouped_collection_select( @object_name, :name, grouped_collection, :last, :first, :first, :last, (), @default_options.merge() ) else collection = encoded_attribute_collection_for_base @template.collection_select( @object_name, :name, collection, :first, :last, (), @default_options.merge() ) end end |