-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Fix engine's generators #1327
Fix engine's generators #1327
Conversation
dummy application
Always use Rails generators directly, not only if options.full? is given
Hrm, this is a hack around the current bug. Probably the best way to fix is this is by moving the load_generators code from Application to Engine and call it on the engine. We could probably do the same for console and make rails console also work for engines. |
Sure, I'll do some work on this topic. |
"Probably the best way to fix is this is by moving the load_generators code from Application to Engine and call it on the engine. We could probably do the same for console and make rails console also work for engines." Yeah, sounds like a nice solution! BTW, any plans to enable running executables such as bundle and rails within a dummy application in a project? Currently this doesn't work, hence it's complicated to set up a dummy app for testing purposes - you first have to export it out, run your bundle/rails commands, then import the project back into your test folder :( |
IMHO, the only commands we need inside an engine's project are generate and console, as @josevalim already pointed out. |
Sounds good for now. Let's try it out and see how it works in real life scenarios. I would however like to be able to run the bundler commands inside the spec folder, fx to configure a dummy rails app with some other gems in order to see how my engine plays in an app configured with other gems (integration testing). |
The bundler commands aren't provided by Rails and shouldn't be affected. |
I dont think we need commands for engines. We partially handle the engine case in the current commands file, I just think we need to wrap it somewhere. |
Hm, handling all together in one file would be the best solution. But the commands are totally different. |
As you seem fit sir. |
Hm? :) |
If you think it is better to have two different files, gO ahead and try it. Code >>> discussion. |
Indeed, I'll do. |
@flippingbits: for the record, we've tried the "single file application" approach, but this is not optimal and can lead to subtle bugs. Think about that: if you set some config options for an Engine and you leave Application file untouched, how will generators now that they need to us Engine's options? |
Yep, good point, @drogus! I've successfully moved load_generators from Application to Engine and modified the commands by creating rails/engine/commands. |
The new pull request is available: #1356. |
Hi all,
this is a fix for Rails generators inside an engine. They currently depend on the dummy app that breaks them if no dummy app exists (e.g. if test unit files are skipped).
I've extracted the generators and added a new class Application inside the lib folder, that provides a Rails::Application but doesn't get loaded by Rails applications that use the engine.
This fixes issue #1259.
Regards