This project is archived and is in readonly mode.
Incorrect migrations when using pluralize_table_names
-
JS
- Tag changed from generators, migrations to generators, migrations, patch
FIX
generator.rb lines 237:
This @tablename = @classnesting.underscore << "" << @tablename
Should be @tablename = @classnesting.gsub("::", "").gsub("/", "").underscore << "" << @tablename
-
JS
I'm sorry, the file name is railties/lib/rails_generator/base.rb
This does not fix the wrong filename.
-
JS
- Tag changed from generators, migrations, patch to bug, generators, migrations, patch
I attached fixed railties/lib/rails_generator/base.rb
-
Pratik
- State changed from new to incomplete
Could you please upload a patch w/tests as described at http://rails.lighthouseapp.com/p...
Thanks.
-
CancelProfileIsBroken
- Tag changed from bug, generators, migrations, patch to bug, bugmash, generators, migrations, patch
-
Peer Allan
Verified in 2.3-stable
To replicate:
- generated new app - add "ActiveRecord::Base.pluralize_table_names = false" to environment.rb - in terminal, $ script/generate model Fruit::Apple::Fuji - results in migration file: 2009xxxxxxx_create_fruit_apple_fujis.rb - class name in the file is also pluralized - create_table is invalidThe table name in the migration is invalid regardless of the pluralization setting when there is more than one namespace associated to the model.
The fix in the attached base.rb file is valid. Attempting to create a patch and tests, but having trouble finding the generator tests.
-
Hugo Peixoto
verified in master.
There were no tests whatsoever related to nested namespaced models generation.
I've attached a patch which adds a substancial amount of test cases, as well as a fix for both bugs reported here.It doesn't work on 2-3-stable, due to all the files moving around in the railties. The tests could probably be used in 2-3-stable, though.
-
Repository
- State changed from incomplete to committed
(from [22b38c18c61a18babd671b973e804e054ba795d4]) Fixed generating a namespaced model with table pluralization turned off. Add tests for namespaced model generation.
[#767 Incorrect migrations when using pluralize_table_names state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/22b38c18c61a18babd671b973e804e... -
Jeremy Kemper
- Assigned user set to Jeremy Kemper
- State changed from committed to incomplete
- Milestone changed from 2.x to 2.3.4
Now targeting a backport to 2.3.
-
Hugo Peixoto
- Assigned user cleared.
I've attached a patch which works in 2-3-stable, and contains the same features as the master patch that I've added before.
-
Hugo Peixoto
- Assigned user set to Jeremy Kemper
-
Jatinder Singh
+1 verified, very nice work on tests.
Applying the 2-3-stable patch gives me trailing whitespace errors though.
-
José Valim
- State changed from incomplete to resolved
- Tag changed from bug, bugmash, generators, migrations, patch to bug, generators, migrations, patch
