This project is archived and is in readonly mode.
AppGenerator generates incorrect application module name under certain circumstances
-
Fred Wu
- Tag changed from appgenerator, app_name, generators, thor to rails 3, rails 3.0 generators, appgenerator, app_name, edge, generators, thor
-
Fred Wu
- Tag changed from rails 3, rails 3.0 generators, appgenerator, app_name, edge, generators, thor to rails 3, rails 3.0 generators, appgenerator, app_name, edge, generator, generators, patch, thor
-
Damien MATHIEU
Actually it's already been fixed here : http://github.com/rails/rails/commit/5d3e8ee2bdd2225fe6e610c7e465bb...
-
Fred Wu
Thanks Damien, I overlooked that commit.
Having said that, this patch works a bit differently (I guess it's kinda like a feature request too) -
If we've generated the app and moved its location (i.e. the app folder's name is changed), the app_name would still parse the name from the folder name. This will result in inconsistent application module naming.
My patch seeks for an existing app module name and use that, so it is more accurate.
Any thoughts?
-
Damien MATHIEU
- Assigned user set to José Valim
That's a question of philosophy and it should be discussed with the core team.
The last change on app_const_base was by José. I'm assigning this ticket to him. -
José Valim
- Importance changed from to Low
Fred, if you are accessing Rails.application, it means a Rails::Application is defined. Couldn't you then simply do: Rails.application.class.name.sub(/::Application$/, "")? The patch in general looks good.
-
Fred Wu
Hi Jose,
I just did a bit more testing.
Rails.applicationcan be access fine within the real world environment, but in testing, it does not work because it has a 'hacked-up' Rails app calledTestApp(defined intest/abstract_unit). This is why in the AppGeneratorRails.appilcation.config.rootis used instead ofRails.root.Do you guys have any suggestions?
If the original AppGenerator changes are acceptable, I will submit a new patch with updated test.
-
José Valim
The idea of the original patch is correct, but I would prefer if it could use
Rails.application.class.name. About the tests, you can stub Rails.application to return an instance of a fake class with the name you want to test! Thanks! -
Fred Wu
Thanks Jose. (Apparently I'm too unwell to remember stubing.)
Attaches is the updated patch. :)
-
Repository
- State changed from new to resolved
(from [cdad483dff4fef1b640dc3c750719c325b252f89]) Improved how AppGenerator generates the application name. It now detects the current app name whenever possible. This means that renaming the residing directory will not effect the app name generated by AppGenerator.
[#5225 AppGenerator generates incorrect application module name under certain circum... state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/cdad483dff4fef1b640dc3c750719c...
