You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When rails_admin is configured to show all models, the dashboard breaks. Since Rails 6 code has models for new features (ActionText and ActionMailbox) that define database tables, these two come up as a problem for rails admin when the tables do not actually exist.
Workaround
short variant for users attempting the rails 6 upgrade:
have rails_admin installed without any models configuration
upgrade an application to rails 6 (currently only as release candidate)
open rails_admin dashboard
Error
an error like this occurs (depends on the database):
PG::UndefinedTable - ERROR: relation "action_mailbox_inbound_emails" does not exist
LINE 8: WHERE a.attrelid = '"action_mailbox_inbound_emails"'::regcl...
Fix
I took a dive in the source code and I think that I could submit pull request for the fix. However, before I do that, would need to know which direction you find more appropriate. I tried two fixes as monkey patch in the rails_admin initialilzer.
One way could be explicitly excluding these models from the models_pool:
But well, it looks like this would just continue to grow and grow.
So maybe when we collect all the models we should filter out the ActiveRecord classes with a call to table_exists?. But I don’t know how big of a performance hit it would be to ask this for dozens of activerecord classes…
moduleRailsAdminclassAbstractModeldefinitialize(model_or_model_name)@model_name=model_or_model_name.to_sancestors=model.ancestors.collect(&:to_s)# following line is monkey-patchedifancestors.include?('ActiveRecord::Base') && !model.abstract_class? && model.table_exists?initialize_active_recordelsifancestors.include?('Mongoid::Document')initialize_mongoidendendendend
Since I consider this high priority I would start the pull request when you say go, but feel also free to grab the snippets :)
The text was updated successfully, but these errors were encountered:
klyonrad
added a commit
to klyonrad/lazybar
that referenced
this issue
Jun 22, 2019
Problem
When rails_admin is configured to show all models, the dashboard breaks. Since Rails 6 code has models for new features (
ActionText
andActionMailbox
) that define database tables, these two come up as a problem for rails admin when the tables do not actually exist.Workaround
short variant for users attempting the rails 6 upgrade:
more detailed stuff below
Reproduction
Error
an error like this occurs (depends on the database):
Fix
I took a dive in the source code and I think that I could submit pull request for the fix. However, before I do that, would need to know which direction you find more appropriate. I tried two fixes as monkey patch in the rails_admin initialilzer.
One way could be explicitly excluding these models from the models_pool:
But well, it looks like this would just continue to grow and grow.
So maybe when we collect all the models we should filter out the ActiveRecord classes with a call to table_exists?. But I don’t know how big of a performance hit it would be to ask this for dozens of activerecord classes…
Since I consider this high priority I would start the pull request when you say go, but feel also free to grab the snippets :)
The text was updated successfully, but these errors were encountered: