Added Support for App Names with Dots in Them#22
Open
HandyAndyShortStack wants to merge 1 commit intorails:masterfrom
Open
Added Support for App Names with Dots in Them#22HandyAndyShortStack wants to merge 1 commit intorails:masterfrom
HandyAndyShortStack wants to merge 1 commit intorails:masterfrom
Conversation
…ue used in rails 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:
$ rails app.name.with.dots.in.it create ...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_baseto '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
.classifyand.underscore.classifyin 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