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

Developer UX: better error for misspelled/missing attribute #246

Closed
monkbroc opened this issue Nov 16, 2015 · 4 comments
Closed

Developer UX: better error for misspelled/missing attribute #246

monkbroc opened this issue Nov 16, 2015 · 4 comments
Milestone

Comments

@monkbroc
Copy link
Contributor

If a field in COLLECTION_ATTRIBUTES has no key in ATTRIBUTE_TYPES either because I misspelled it or I forget to add it to ATTRIBUTE_TYPES I will get a undefined method new for nil:NilClass in Page::Base

It would be nicer to see a custom exception Attribute xyz not found in dashboard AbcDashboard

This has already happened multiple times on my first day of using Administrate so I think this is worthwhile to fix.

@c-lliope
Copy link
Contributor

👍 good call, I think this would be super useful.

@c-lliope c-lliope added this to the v0.1.2 milestone Nov 16, 2015
@5minpause
Copy link
Contributor

@Graysonwright @monkbroc I gave a possible implementation a try.
https://github.com/ikuseiGmbH/administrate/commit/62570b673bd43964db8d9dfc09b6fddb1ec7b8be

Could you provide feedback, please? I wasn't sure how to add a test for that. Any hints would be appreciated.
Also I don't know how Thoughtbot deals with HEREDOCS? Do you use indentation?

@monkbroc
Copy link
Contributor Author

Thanks @5minpause. I commented on your commit.

@c-lliope
Copy link
Contributor

@5minpause can you open a PR for that commit, so we can leave comments on it more effectively?

For HEREDOCs, I usually go with this:

  string = <<-SOMETHING.strip_heredoc
    If you use `<<-` instead of `<<`,
    it lets you indent the closing tag.
    The `strip_heredoc` removes leading indentation
    for the heredoc string.
  SOMETHING

Sources:
http://rubyquicktips.com/post/4438542511/heredoc-and-indent
http://apidock.com/rails/String/strip_heredoc

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

No branches or pull requests

3 participants