Browse files

AS guide: adds a real example for #pluralize

  • Loading branch information...
1 parent 947511e commit 51e84bfbd6e53cef8b563bdf99ea47631bece677 @fxn fxn committed Mar 1, 2010
Showing with 11 additions and 0 deletions.
  1. +11 −0 railties/guides/source/active_support_core_extensions.textile
View
11 railties/guides/source/active_support_core_extensions.textile
@@ -1263,6 +1263,17 @@ The method +pluralize+ returns the plural of its receiver:
As the previous example shows, Active Support knows some irregular plurals and uncountable nouns. Builtin rules can be extended in +config/initializers/inflections.rb+. That file is generated by the +rails+ command and has instructions in comments.
+Active Record uses this method to compute the default table name that corresponds to a model:
+
+<ruby>
+# active_record/base.rb
+def undecorated_table_name(class_name = base_class.name)
+ table_name = class_name.to_s.demodulize.underscore
+ table_name = table_name.pluralize if pluralize_table_names
+ table_name
+end
+</ruby>
+
NOTE: Defined in +active_support/core_ext/string/inflections.rb+.
h3. Extensions to +Numeric+

0 comments on commit 51e84bf

Please sign in to comment.