diff options
author | Xavier Noria <fxn@hashref.com> | 2010-03-01 05:35:01 +0100 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2010-03-01 05:35:01 +0100 |
commit | 51e84bfbd6e53cef8b563bdf99ea47631bece677 (patch) | |
tree | 7e11e710e7f765b9446953e048355bfafb0db23c /railties/guides | |
parent | 947511e50e7c60d8bed581c8f20f4ebbc72a4d14 (diff) | |
download | rails-51e84bfbd6e53cef8b563bdf99ea47631bece677.tar.gz rails-51e84bfbd6e53cef8b563bdf99ea47631bece677.tar.bz2 rails-51e84bfbd6e53cef8b563bdf99ea47631bece677.zip |
AS guide: adds a real example for #pluralize
Diffstat (limited to 'railties/guides')
-rw-r--r-- | railties/guides/source/active_support_core_extensions.textile | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index 23879827e2..7ee414f34b 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/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+ |