-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Better error message if key is not specified in ATTRIBUTE_TYPES #1762
Conversation
@nickcharlton @pablobm @sedubois guys, can someone take a look please? It is a small change but I find it very useful - helps you debug thing when you messed up dashboard by not declaring some attributes. |
i got so used to this error that didn't pay attention, but i wanted to say this is an elegant change @inem - hope it gets merged soon as we're seeing more activities on master again :) |
lib/administrate/base_dashboard.rb
Outdated
@@ -88,7 +88,7 @@ def attribute_not_found_message(attr) | |||
|
|||
def attribute_includes(attributes) | |||
attributes.map do |key| | |||
field = self.class::ATTRIBUTE_TYPES[key] | |||
field = self.class::ATTRIBUTE_TYPES.fetch(key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call; thank you. Since we are at it, how about using attribute_type_for
instead? That way we also get a more descriptive error than just a KeyError
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I didn't know what is attribute_type_for
Now googled and found that it is an internal administrate method.
Kind of done, I guess.
+1 for this change. |
Looks good! Could you please rebase so that the build passes? The errors should just be about security advisories in dependencies, but it's worth seeing it green before merging. |
to provide better error description if something goes wrong. Currently I get "NoMethodError: undefined method `associative?' for nil:NilClass"
0a050c9
to
0e53a06
Compare
I was getting:
After the change: