-
Notifications
You must be signed in to change notification settings - Fork 61
Add an explicit require for "active_record" #112
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 an explicit require for "active_record" #112
Conversation
|
While I understand why this problem would be happening, it is not quite how the gem is intended to be used and should not occur for the average Rails app (and specifically once your Rails app boots/initializes). Is there something that you're trying to do in particular? |
|
Fair question - in our case we have a number of gems which form the basis of engines, and we also have a gem who's job is to do nothing but prepare all of our test gems for the spec phase. It is that gem which is showing this issue - we can't set up that gem and point it at another gem which is an engine. Actually I also notice it is a problem for any rubygem engine that uses Combustion but doesn't initialize ActiveRecord (since it may not need it). I do see that this may be less common.... A more compelling reason is that any gem must require its own dependencies, and it is violating rubygem specificaitons if it doesn't. In this case it is (almost!) certain that the load order will be right, but this change can handle rare(r) cases? |
|
@hlascelles Thanks for providing some more details, and that makes sense — it's true engines are rare but they are a feature of Rails and should be supported. If there's a way to replicate the setup for an engine in the tests, then I'm happy to merge this fix. The bit of code you provided would work fine of course but I don't want to lose the use case where this originated so I'd rather get closer to that. Currently the way the integration tests work is that a Rails application is generated on the fly, and so ideally we'd want to do the same thing for engines. The setup for that is a little complicated, so I'm inclined to take that step over rather than have you do this. Do you by chance have a repo that could serve as an example, or should I just try generating an engine using Combustion and starting with that? |
|
I've added a few files that can demonstrate the issue with a combustion app. Just Thank you for looking into this, yes, it would be a great help if you added it to the tests the best way to fit everything else. Hopefully I've added enough for that to be trivial. 👍 |
|
I took a look at your example and thought about this a bit more. If you have an engine that does not rely on ActiveRecord, I'm not sure that explicitly requiring ActiveRecord is the best answer, because then the gem is loading code that you don't want. Rather, since |
|
Interesting points, I see what you mean. Yes, that would work. It would keep the "plug and play" simple. Go for it - and nice to see Combustion tests going in! 👍 But also... I suppose if the (good) intent is to make everything "just work" you could remove the need to |
|
Hey, sorry for the long delay in responding to this PR. I appreciate the test setup you provided here. I decided to keep your suggestion of allowing people to still use |
It is possible for
super_diffto break withrailsif required in a certain order.You can demonstrate by running this file:
You get:
This PR covers for that case.