From b8e4f7155b9c06842f1d9d17f36886cb663aa3a4 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Fri, 27 Jul 2012 23:38:34 -0500 Subject: add example to ActiveModel::Naming#model_name [ci skip] --- activemodel/lib/active_model/naming.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'activemodel/lib/active_model') 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| -- cgit v1.2.3