Added Support for App Names with Dots in Them #22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I encountered a bug when using this gem to upgrade some legacy rails 2 applications. When the name of the root directory for these apps included dots, the application name generated by the routes upgrader and configuration generator were inconsistent with the way rails 3 handles such root directory names. Specifically, the part of the directory name following the last dot was used. Here is an example using rails 2:
Notice that the new routes file contains the line
and the code for config/application.rb includes the line
Had the application been generated in rails 3 using
rails new app.name.with.dots.in.it
, those lines would readand
respectively.
Rails 3 seems to use the method
Rails::Generators::AppGenerator.app_const_base
to 'classify' the app name. Here is the code, retrieved from http://api.rubyonrails.org/classes/Rails/Generators/AppGenerator.html#method-i-app_const_baseby replacing the
.classify
and.underscore.classify
in the places where rails_upgrade generates this app_const_base string with.gsub(/\W/, '_').squeeze('_').camelize
, we can better emulate a new rails 3 app. Here are the results using my fork:Thank you so much for making this plugin! It has helped me out immensely. I hope this pull request will help prevent headaches for future developers if you accept it.
-Andy