-
Notifications
You must be signed in to change notification settings - Fork 168
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
How to exclude all models from engine? #4
Comments
Hi @bjensen I think this is because in development classes are lazy loaded so when the initializer is executed models are not loaded yet. |
I think you are right..but do you have any suggestions as to how to get it working in development except for actually having to cut and paste every model name and remember to add to this list whenever we add a new model etc? |
I don't have the solution for this issue, but you should check rails eager_loading: https://guides.rubyonrails.org/autoloading_and_reloading_constants.html#eager-loading |
@bjensen
Out of curiosity, what is the use case behind this? EDIT: Forget what i just said. I've read through the thing again... I don't think that you'll be able to get around it without loading the classes. The other option (more prone to errors) is to try to convert the table names onto models. Eg.
|
Does |
Closing this as it doesn't seem needed anyhow else. If this becomes an issue we can look at the use case |
I tried adding this to the apartment initializer:
This works perfectly when run in the console, however engine_models is empty when its being executed as part of initialisation. Does anyone have a good idea?
This is in Rails 6.0.2.1
The text was updated successfully, but these errors were encountered: