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
Merged
nickcharlton
merged 1 commit into
thoughtbot:master
from
pablobm:better-generator-warnings
Feb 14, 2020
Merged
More readable warnings #1551
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,15 +20,15 @@ def insert_dashboard_routes | |
end | ||
|
||
def warn_about_invalid_models | ||
namespaced_models.each do |invalid_model| | ||
puts "WARNING: Unable to generate a dashboard for #{invalid_model}." | ||
puts " Administrate does not yet support namespaced models." | ||
end | ||
|
||
models_without_tables.each do |invalid_model| | ||
puts "WARNING: Unable to generate a dashboard for #{invalid_model}." | ||
puts " It is not connected to a database table." | ||
puts " Make sure your database migrations are up to date." | ||
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." | ||
end | ||
if models_without_tables.include?(model) | ||
puts " - It is not connected to a database table." | ||
puts " Make sure your database migrations are up to date." | ||
end | ||
end | ||
|
||
unnamed_constants.each do |invalid_model| | ||
|
@@ -49,15 +49,15 @@ def dashboard_resources | |
end | ||
|
||
def valid_dashboard_models | ||
database_models - invalid_database_models | ||
database_models - invalid_dashboard_models | ||
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, the inconsistent naming was bothering me too. |
||
(models_without_tables + namespaced_models + unnamed_constants).uniq | ||
end | ||
|
||
def models_without_tables | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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!