06 - understanding pluralization rules.rb

来自「O Reilly Ruby Cookbook source code」· RB 代码 · 共 39 行

RB
39
字号
class Order < ActiveRecord::Base  has_many :line_itemsend#---Rails::Initializer.run do |config|  config.active_record.pluralize_table_names = falseend#---Inflector.inflections do |inflect|  inflect.plural /^(foo)$/i, '\1ze'  inflect.singular /^(foo)ze/i, '\1'end#---Inflector.inflections do |inflect|  inflect.irregular 'foo', 'fooze'end#---Inflector.inflections do |inflect|  inflect.uncountable ['status', 'furniture', 'fish', 'sheep']end#---require 'rubygems'require 'active_support/core_ext''blob'.pluralize                                 # => "blobs"'child'.pluralize                                # => "children"'octopus'.pluralize                              # => "octopi"'octopi'.singularize                             # => "octopus"'people'.singularize                             # => "person"'goose'.pluralize                                # => "gooses"Inflector.inflections { |i| i.irregular 'goose', 'geese' }'goose'.pluralize                                # => "geese"'moose'.pluralize                                # => "mooses"Inflector.inflections { |i| i.uncountable 'moose' }'moose'.pluralize                                # => "moose"#---

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?