-
Notifications
You must be signed in to change notification settings - Fork 43
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
Configure load paths of controllers and models #106
Configure load paths of controllers and models #106
Conversation
Autoload once the app/controllers and app/models directories to prevent the uninitialized constants error. Removed `require_dependency` since it's obsolete and not needed with autoloading. Removed the note in the readme about Rails 7 NameError.
seems like with Mongoid I am still getting the same issue |
@RoxasShadow Do you have more details on your setup? The error implies that |
Yes indeed, as I use Mongoid, and only load |
@RoxasShadow I was able to replicate this. I pushed a commit to use a string for |
That fixed the issue! Thanks a lot |
There's more to it than that; in development, it'll mean Scimitar initialisation is checked if altered, on reload. Otherwise it's not. https://guides.rubyonrails.org/configuring.html#initialization-events Both the Rails 6 and Rails 7 versions of the gem support (and like many other gems) require As a result I don't really see what this PR is for, especially since it introduces inherent and hard-to-test fragility for anything that might be subject to autoloading in future and would need the @RoxasShadow I don't understand. If you're not using ActiveRecord, you shouldn't be using the AR-backed resource controller. If you're saying that with no use of it, Scimitar's default inclusion chain as a gem means it gets read anyway and as a result you get an undefined constant error, then that's a separate bug / issue and should be addressed in another PR (specifically, not including the AR-backed resources controller; it's IMHO not the right thing to just try to work around around the reference via a string in the |
@pond You are right about reloading constants from extended schemas in development which I hadn't thought about. This change doesn't stop you from using the So this PR just instructs Zeitwerk to autoload the controller and models directory and not eager load them. Autoloading basically just primes the constant lookup table before user defined initializers are ran. Autoloading actually doesn't read the contents of the files interestingly. So I can't really think of how this could add fragility since non-existent folders/files are just ignored. Maybe if you didn't follow zeitwerks naming rules? 🤔 You might have other issues though. Actually thinking about @RoxasShadow issue, this gem as it is won't work without Feel free to close this if you like. |
@afrase I like your cleaning up via removing the requirements lines and adding the load paths into the engine. Reads more like a bug fix than anything else, in fact. I see no reason to remove the So - much as using the string in
|
d673acc
into
RIPAGlobal:feature/configure-load-paths
Hey thanks for the work on this gem. I saw the note on wrapping the initializer in
Rails.application.config.to_prepare
and thought I would fix that. I'm not sure how open you guys are to PRs.require_dependency
since it's obsolete and not needed with autoloading.