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

Add configurable name to the error #59

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

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.

@@ -18,7 +18,11 @@ def update
if failures.empty?
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