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
More readable warnings #1551
More readable warnings #1551
Conversation
invalid_dashboard_models.each do |model| | ||
puts "WARNING: Unable to generate a dashboard for #{model}." | ||
if namespaced_models.include?(model) | ||
puts " - Administrate does not yet support namespaced models." |
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.
Perhaps a different question to ask is: Do we still need this warning? In general, we do support namespaced models. What's missing from the current support which means we should still have this warning?
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.
Exactly. I got here because I was looking into that. The error messages were confusing, so I thought of fixing that first, then looking into generating those namespaces. My thinking is that getting this to work properly may (perhaps) take long, so meanwhile let's at least make this more bearable, which is low-hanging fruit.
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.
Alright, let's do it!
end | ||
|
||
def database_models | ||
ActiveRecord::Base.descendants.reject(&:abstract_class?) | ||
end | ||
|
||
def invalid_database_models | ||
models_without_tables + namespaced_models + unnamed_constants | ||
def invalid_dashboard_models |
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.
This is a nice change!
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.
Yeah, the inconsistent naming was bothering me too.
During normal operation, the routes generator can print a few warnings. When there's more than one reason to trigger a warning for a given resource, these are printed out separately, often with other warnings intereleaved.
For example, these are 8 warning about 4 different resources:
This is a bit difficult to read and can be confusing. Instead, I propose that we group together the warnings related to each given resource, like so:
This PR implements this behaviour.