This project is archived and is in readonly mode.
[PATCH] Avoid app_const when drawing routes in app generator
-
phs
And the patch.
-
Robert Glaser
+1
There should be at least a "--engine" switch for the "rails xy" generator.
-
José Valim
- State changed from new to invalid
Engine will have their own routes soon. So you may want it to have its own routes... or not.
-
José Valim
Engines will have their own routes soon. So you may want to use Module::Engine.routes.draw... or still manipulate Rails.application directly. That said, it does not really makes sense applying your patch because your assertion won't be necessarily valid soon.
-
phs
That's a reasonable stance.
As a related question, suppose the engine author wants to run her engine as a standalone app (i.e. by using a config/application.rb instead of an Engine subclass) without having to change or have multiple routes.rb files around. One way is to always draw from Rails.application.routes like above, another is to explicitly check for some known types first a la
(MyHotNewApp::Application rescue MyHotNewApp::Engine).routes.draw { ... }
Have any preferences for one over the other? I'm totally fine having the engine author (or a support tool) introduce the needed change from the stock routes.rb.
-
José Valim
Yes, today you will need to resort to hacks in order to have a Rails application working as engine too. But there is a Ruby Summer of Code project to make this easier. :)
-
phs
Cool! Incidentally I'd love to be involved in that.
-
José Valim
I think his project already have primary and secondary mentors, but you can of course follow him on twitter (http://twitter.com/drogus) and follow his fork (github.com/drogus/rails).
