提交 1064c533 编写于 作者: X Xavier Noria

AS guide: documents String#singularize

上级 51e84bfb
......@@ -1276,6 +1276,29 @@ end
NOTE: Defined in +active_support/core_ext/string/inflections.rb+.
h5. +singularize+
The inverse of +pluralize+:
<ruby>
"tables".singularize # => "table"
"rubies".singularize # => "ruby"
"equipment".singularize # => "equipment"
</ruby>
Associations compute the name of the corresponding default associated class using this method:
<ruby>
# active_record/reflection.rb
def derive_class_name
class_name = name.to_s.camelize
class_name = class_name.singularize if collection?
class_name
end
</ruby>
NOTE: Defined in +active_support/core_ext/string/inflections.rb+.
h3. Extensions to +Numeric+
h4. Bytes
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册