Method: ActionView::Helpers::InstanceTag#to_enum_select_tag

Defined in:
lib/enumerated_attribute/rails_helpers.rb

#to_enum_select_tag(options, html_options = {}) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/enumerated_attribute/rails_helpers.rb', line 60

def to_enum_select_tag(options, html_options={})
	choices = []
	if self.object.respond_to?(:enums)
		enums = self.object.enums(method_name.to_sym)
		choices = enums ? enums.select_options : []
		if (value = self.object.__send__(method_name.to_sym))
			options[:selected] ||= value.to_s
		else
          options[:include_blank] = enums.allows_nil? if options[:include_blank].nil?
		end
	end
	to_select_tag(choices, options, html_options)
end