aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model
diff options
context:
space:
mode:
authorFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-07-27 23:38:34 -0500
committerFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-07-27 23:38:34 -0500
commitb8e4f7155b9c06842f1d9d17f36886cb663aa3a4 (patch)
tree604ce457b0db0b078cdfa8b3ffae381b129f91c0 /activemodel/lib/active_model
parent36ebafdce959a2cf70f10655df46237020f3270a (diff)
downloadrails-b8e4f7155b9c06842f1d9d17f36886cb663aa3a4.tar.gz
rails-b8e4f7155b9c06842f1d9d17f36886cb663aa3a4.tar.bz2
rails-b8e4f7155b9c06842f1d9d17f36886cb663aa3a4.zip
add example to ActiveModel::Naming#model_name [ci skip]
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r--activemodel/lib/active_model/naming.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/naming.rb b/activemodel/lib/active_model/naming.rb
index 43d11b1b08..30d2da9af7 100644
--- a/activemodel/lib/active_model/naming.rb
+++ b/activemodel/lib/active_model/naming.rb
@@ -220,6 +220,14 @@ module ActiveModel
# Returns an ActiveModel::Name object for module. It can be
# used to retrieve all kinds of naming-related information
# (See ActiveModel::Name for more information).
+ #
+ # class Person < ActiveModel::Model
+ # end
+ #
+ # Person.model_name # => Person
+ # Person.model_name.class # => ActiveModel::Name
+ # Person.model_name.singular # => "person"
+ # Person.model_name.plural # => "people"
def model_name
@_model_name ||= begin
namespace = self.parents.detect do |n|