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
Instance Method Details
#to_enum_select_tag(options, html_options = {}) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/enumerated_attribute/rails_helpers.rb', line 59 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] = enums.allows_nil? if [:include_blank].nil? end end to_select_tag(choices, , ) end |
#to_tag_with_enumerated_attribute(options = {}) ⇒ Object
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/enumerated_attribute/rails_helpers.rb', line 75 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 |