Search code examples
ruby-on-railsruby-on-rails-3introspectionpluralize

Ruby on Rails: how to check pluralized and single form of names


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 ?


Solution

  • You can do this in the rails console.

    $ "anonymous".pluralize
    => "anonymous" 
    

    or another example where the plural word is different.

    $ "cookie".pluralize
    => "cookies"