Module: AUStateSelect::TagHelper

Defined in:
lib/au_state_select/tag_helper.rb

Instance Method Summary collapse

Instance Method Details

#state_option_tagsObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/au_state_select/tag_helper.rb', line 3

def state_option_tags
  # In Rails 5.2+, `value` accepts no arguments and must also be called
  # called with parens to avoid the local variable of the same name
  # https://github.com/rails/rails/pull/29791
  selected_option = @options.fetch(:selected) do
    if self.method(:value).arity == 0
      value()
    else
      value(@object)
    end
  end

  option_tags_options = {
    :selected => selected_option,
    :disabled => @options[:disabled]
  }
  option_tags = options_for_select(state_options, option_tags_options)
end