This project is archived and is in readonly mode.
Incorrect migrations when using pluralize_table_names
Reported by JS | August 6th, 2008 @ 09:37 PM | in 2.3.4
This happens both with the latest (2.1) gem version and the latest git version.
environment.rb:
config.activerecord.pluralizetable_names = false
./script/generate migration fruits/delicious/apple
will produce file: 20080806203144createfruitsdeliciousapples
class CreateFruitsDeliciousApples < ActiveRecord::Migration def self.up
create_table :fruits/delicious_apple do |t|
t.timestamps
end
end
def self.down
drop_table :fruits/delicious_apple
end end
Fixes needed: 1.File name and class name should be singular. 2.:fruits/deliciousapple should be :fruitsdelicious_apple
Comments and changes to this ticket
-
JS August 6th, 2008 @ 10:06 PM
- 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 August 6th, 2008 @ 10:12 PM
I'm sorry, the file name is railties/lib/rails_generator/base.rb
This does not fix the wrong filename.
-
JS August 6th, 2008 @ 10:20 PM
- no changes were found...
-
JS August 6th, 2008 @ 10:20 PM
- Tag changed from generators, migrations, patch to bug, generators, migrations, patch
I attached fixed railties/lib/rails_generator/base.rb
-
Pratik August 22nd, 2008 @ 03:19 AM
- State changed from new to incomplete
Could you please upload a patch w/tests as described at http://rails.lighthouseapp.com/p...
Thanks.
-
CancelProfileIsBroken August 3rd, 2009 @ 03:08 PM
- Tag changed from bug, generators, migrations, patch to bug, bugmash, generators, migrations, patch
-
Peer Allan August 9th, 2009 @ 05:11 AM
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 August 9th, 2009 @ 10:30 AM
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 August 9th, 2009 @ 10:41 AM
- 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 state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/22b38c18c61a18babd671b973e804e... -
Jeremy Kemper August 9th, 2009 @ 10:43 AM
- 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 August 9th, 2009 @ 11:29 AM
- 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 August 9th, 2009 @ 11:36 AM
- Assigned user set to Jeremy Kemper
-
Jatinder Singh August 9th, 2009 @ 12:15 PM
+1 verified, very nice work on tests.
Applying the 2-3-stable patch gives me trailing whitespace errors though.
-
José Valim August 9th, 2009 @ 04:00 PM
- State changed from incomplete to resolved
- Tag changed from bug, bugmash, generators, migrations, patch to bug, generators, migrations, patch
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 767 Incorrect migrations when using pluralize_table_names [#767 state:committed]