Skip to content

Add configurable name to the error#59

Open
bcardiff wants to merge 1 commit intopaulca:masterfrom
bcardiff:validation-error-context
Open

Add configurable name to the error#59
bcardiff wants to merge 1 commit intopaulca:masterfrom
bcardiff:validation-error-context

Conversation

@bcardiff
Copy link

When updating a value with an invalid type the flash[:error] message only says "invalid value" (or whatever is stated in activerecord.errors.messages.invalid i18n). There is no contextual information for the user regarding which configurable is failing.

This PR addresses that by prefixing the message with the configurable name.

Another alternative would be add a custom i18n friendly error key for this. But I didn't want to introduce more than what was needed.

redirect_to(action: :show, :notice => "Changes successfully updated")
else
flash[:error] = failures.flat_map(&:errors).flat_map(&:full_messages).join(',')
flash[:error] = failures.map { |c| [c, c.errors] }.flat_map { |c, e|
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a test for this behavior? Then happy to merge. Also: miss u

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You maintain this gem?! I missed that. And you 💙

The spec would need to be inside feature, right? Because I don't see plain controller specs in the codebase.

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.

2 participants