Browse files

add example to ActiveModel::Naming#model_name [ci skip]

  • Loading branch information...
1 parent 36ebafd commit b8e4f7155b9c06842f1d9d17f36886cb663aa3a4 Francesco Rodriguez committed Jul 27, 2012
Showing with 8 additions and 0 deletions.
  1. +8 −0 activemodel/lib/active_model/naming.rb
View
8 activemodel/lib/active_model/naming.rb
@@ -220,6 +220,14 @@ module Naming
# 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|

0 comments on commit b8e4f71

Please sign in to comment.