Skip to content

Conversation

@codeodor
Copy link

@codeodor codeodor commented Apr 28, 2016

If the key :errors exists in @options then the previous code will return nil if errors was nil.

Changing it like this ensures we have a hash if errors did not exist or if it was nil.

If the key `:errors` exists in `@options` then the previous code will return `nil`.

Changing it like this ensures we have a hash if errors did not exist or if it was nil.
@coveralls
Copy link

coveralls commented Apr 28, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling f0a16f2 on codeodor:codeodor-nil-errors into 88a6398 on Fullscreen:master.

@Manifold0
Copy link

This happens again further down in the :show_error_help? method

def show_error_icon?(field_type, errors, suffix = nil)
    no_icon = %w(checkbox number_field radio_button select legend)
    hide = no_icon.include?(field_type.to_s)
    # errors.any? && @options.fetch(:errors, {}).fetch(:icons, true) && !hide && suffix.nil?
    errors.any? && (@options.fetch(:errors, {}) || {}).fetch(:icons, true) && !hide && suffix.nil?
  end

  def show_error_help?
    # @options.fetch(:errors, {}).fetch(:messages, :inline).to_s == 'inline'
    (@options.fetch(:errors, {}) || {}).fetch(:messages, :inline).to_s == 'inline'
  end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants