10

I have created a model Anonymous with command

rails g model Anonymous section_id:integer aid:string fake:bool active:bool

but table name in the migration is called anonymous

class CreateAnonymous < ActiveRecord::Migration
  def change
    create_table :anonymous do |t|
      t.integer :section_id
      t.string :aid
      t.bool :fake
      t.bool :active

      t.timestamps
    end
  end
end

Am i right that pluralized form of Anonymous is Anomymous too ? (English is not my native language). How can i see what pluralized names Rails gives to my models ? Something like rake routes ?

Puce
  • 1,003
  • 14
  • 28
s9gf4ult
  • 862
  • 6
  • 20
  • The other answers talk about how the Rails pluralize stuff works, so you can see what the table name is. I'll add that in English, "anonymous" is an adjective, not a noun, and so doesn't normally have a plural form. Maybe you mean something like AnonymousUser or AnonymousComment? – dpassage Nov 06 '12 at 06:36

3 Answers3

22

You can do this in the rails console.

$ "anonymous".pluralize
=> "anonymous" 

or another example where the plural word is different.

$ "cookie".pluralize
=> "cookies" 
Robert B
  • 2,863
  • 4
  • 31
  • 40
2
pluralize(count, singular, plural = nil) public

Attempts to pluralize the singular word unless count is 1. If plural is supplied, it will use that when count is > 1, otherwise it will use the Inflector to determine the plural form

Examples:

pluralize(1, 'person')
# => 1 person

pluralize(2, 'person')
# => 2 people

pluralize(0, 'person')
# => 0 people

for you

"anonymous".pluralize
user229044
  • 232,980
  • 40
  • 330
  • 338
Dipak Panchal
  • 5,996
  • 4
  • 32
  • 68
0

I'd just rename your model. Save yourself the pain and future debugging and just avoid this potential headache. You could use "Anonymouse" with plural "Anonymouses". Or think up a more clever name.

hellion
  • 4,602
  • 6
  • 38
  • 77