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

Add config.included_models #204

Open
ramaboo opened this issue May 31, 2022 · 1 comment
Open

Add config.included_models #204

ramaboo opened this issue May 31, 2022 · 1 comment

Comments

@ramaboo
Copy link

ramaboo commented May 31, 2022

We run a large app where 90% of our app is not using Apartment. We really only use it for two tables. This makes config.excluded_models not work so well for us as ever new model we add we have to go and manually exclude it. It would be much simpler if we could do config.included_models instead. Right now we run code like this:

      included_models = %w[Widget Classification]
      manual_exclude = %w[UserRole]
      active_storage = %w[ActiveStorage::Attachment ActiveStorage::Blob ActiveStorage::VariantRecord]
      all_models = ApplicationRecord.connection.tables.map do
        model_name = _1.capitalize.singularize.camelize

        Module.const_defined?(model_name) ? model_name : nil
      end.compact.sort

      config.excluded_models = all_models - included_models + manual_exclude + active_storage
      

But it's not ideal and error prone. I was wondering if there are any plans to support config.included_models or if someone familiar with the code base could point me in a direction for starting that work?

@kapso
Copy link

kapso commented Jun 24, 2022

We use this popular gem Rolify (https://github.com/RolifyCommunity/rolify) - which uses an internal table (for some internal join queries), that is not manifested as an ActiveRecord model, and thus there's no way to manifest it as an excluded_models.

An included_models option will make this gem more compatible with other gems.

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

2 participants