Class: ActionView::Helpers::InstanceTag
- Inherits:
-
Object
- Object
- ActionView::Helpers::InstanceTag
- Defined in:
- lib/enumerated_attribute/rails_helpers.rb
Instance Method Summary collapse
- #to_enum_select_tag(options, html_options = {}) ⇒ Object
-
#to_tag_with_enumerated_attribute(options = {}) ⇒ Object
initialize record_name, method, self.
Instance Method Details
#to_enum_select_tag(options, html_options = {}) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/enumerated_attribute/rails_helpers.rb', line 52 def to_enum_select_tag(, ={}) choices = [] if self.object.respond_to?(:enums) enums = self.object.enums(method_name.to_sym) choices = enums ? enums. : [] if (value = self.object.__send__(method_name.to_sym)) [:selected] ||= value.to_s else [:include_blank] ||= true end end to_select_tag(choices, , ) end |
#to_tag_with_enumerated_attribute(options = {}) ⇒ Object
initialize record_name, method, self
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/enumerated_attribute/rails_helpers.rb', line 67 def to_tag_with_enumerated_attribute(={}) #look for an enum if (column_type == :string && self.object.class.respond_to?(:has_enumerated_attribute?) && self.object.class.has_enumerated_attribute?(method_name.to_sym)) to_enum_select_tag() else to_tag_without_enumerated_attribute() end end |