aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/active_model_basics.md
diff options
context:
space:
mode:
authorAditya Kapoor <aditya.kapoor@vinsol.com>2014-07-05 22:14:03 +0530
committerAditya Kapoor <aditya.kapoor@vinsol.com>2014-07-05 22:14:03 +0530
commit8c8e5be9c97eaf7e88b0cefafdc191108c19d1b6 (patch)
treed67461e5c05f4c71b4af621b196ff6b20d3df703 /guides/source/active_model_basics.md
parent081eec4ba68d161623791d4f6c885ce0d442f31c (diff)
downloadrails-8c8e5be9c97eaf7e88b0cefafdc191108c19d1b6.tar.gz
rails-8c8e5be9c97eaf7e88b0cefafdc191108c19d1b6.tar.bz2
rails-8c8e5be9c97eaf7e88b0cefafdc191108c19d1b6.zip
[ci skip] add guide for ActiveModel::Naming
Diffstat (limited to 'guides/source/active_model_basics.md')
-rw-r--r--guides/source/active_model_basics.md23
1 files changed, 23 insertions, 0 deletions
diff --git a/guides/source/active_model_basics.md b/guides/source/active_model_basics.md
index 0019d08328..1131a83c36 100644
--- a/guides/source/active_model_basics.md
+++ b/guides/source/active_model_basics.md
@@ -198,3 +198,26 @@ person.valid? # => true
person.token = nil
person.valid? # => raises ActiveModel::StrictValidationFailed
```
+
+### ActiveModel::Naming
+
+Naming adds a number of class methods which make the naming and routing
+easier to manage. The module defines the `model_name` class method which
+will define a number of accessors using some `ActiveSupport::Inflector` methods.
+
+```ruby
+class Person
+ extend ActiveModel::Naming
+end
+
+Person.model_name.name # => "Person"
+Person.model_name.singular # => "person"
+Person.model_name.plural # => "people"
+Person.model_name.element # => "person"
+Person.model_name.human # => "Person"
+Person.model_name.collection # => "people"
+Person.model_name.param_key # => "person"
+Person.model_name.i18n_key # => :person
+Person.model_name.route_key # => "people"
+Person.model_name.singular_route_key # => "person"
+``` \ No newline at end of file