Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@options.fetch(:errors, {}) can be nil #162

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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