Ruby on Rails:如何检查名称的复数形式和单一形式 [英] Ruby on Rails: how to check pluralized and single form of names

查看:105
本文介绍了Ruby on Rails:如何检查名称的复数形式和单一形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用命令

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

我对吗,Anonymous的复数形式也是Anomymous吗? (英语不是我的母语).我如何看待Rails给我的模型赋予的复数名称?类似于rake routes吗?

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 ?

推荐答案

您可以在rails控制台中执行此操作.

You can do this in the rails console.

$ "anonymous".pluralize
=> "anonymous" 

或复数词不同的另一个示例.

or another example where the plural word is different.

$ "cookie".pluralize
=> "cookies" 

这篇关于Ruby on Rails:如何检查名称的复数形式和单一形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆