This project is archived and is in readonly mode.

#2674 ✓duplicate
Stephen Celis

Namespaced model table name inconsistency

Reported by Stephen Celis | May 19th, 2009 @ 12:48 AM | in 2.x

Example you:

% script/generate model user/tag
      create  app/models/user
      create  test/unit/user
      create  test/fixtures/user
      create  app/models/user/tag.rb
      create  test/unit/user/tag_test.rb
      create  test/fixtures/user_tags.yml
      exists  db/migrate
      create  db/migrate/20090518233442_create_user_tags.rb
% rake db:migrate
==  CreateUserTags: migrating =================================================
-- create_table(:user_tags)
   -> 0.0022s
==  CreateUserFlags: migrated (0.0029s) =======================================
% script/console
>> User::Tag
=> User::Tag(Table doesn't exist)
>> User::Tag.table_name
=> "tags"

So:

  1. Migration generates table name that accounts for namespace.
  2. Model suppresses namespace when assuming table name.

I'm happy to provide a patch, but what's the expected behavior? It seems to me that namespaces should persist to the table.

Comments and changes to this ticket

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

Pages