diff --git a/lib/subdivision_select/tag_helper.rb b/lib/subdivision_select/tag_helper.rb index 3fec4fd..9fb55d8 100644 --- a/lib/subdivision_select/tag_helper.rb +++ b/lib/subdivision_select/tag_helper.rb @@ -2,8 +2,19 @@ module SubdivisionSelect #class CountryNotFoundError < StandardError;end module TagHelper def subdivision_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: @options.fetch(:selected) { value(@object) }, + selected: selected_option, disabled: @options[:disabled] }