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

In a nested form, options[:errors] can be nil #142

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

kakra
Copy link

@kakra kakra commented Jul 10, 2015

The problem here is:

{ errors: nil }.fetch(:errors, {}) #==> nil

but the code expects:

({ errors: nil }.fetch(:errors) || {}) #==> {}

for the chained #fetch to work.

These patches fix the two problematic lines, though a more sophisticated patch should fix why in fields_for can the key exists with a nil value in first place.

The problem here is:

    { errors: nil }.fetch(:errors, {}) #==> nil

but the code expects:

    ({ errors: nil }.fetch(:errors) || {}) #==> {}

for the chained ```#fetch``` to work.

This patch fixes it, though a more sophisticated patch should fix why in ```fields_for``` can the key exists with a nil value in first place.
Without the default option, ```#fetch``` won't full back but report "key not found".
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.

1 participant