mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
add example to ActiveModel::Naming#model_name [ci skip]
This commit is contained in:
parent
36ebafdce9
commit
b8e4f7155b
1 changed files with 8 additions and 0 deletions
|
@ -220,6 +220,14 @@ module ActiveModel
|
||||||
# Returns an ActiveModel::Name object for module. It can be
|
# Returns an ActiveModel::Name object for module. It can be
|
||||||
# used to retrieve all kinds of naming-related information
|
# used to retrieve all kinds of naming-related information
|
||||||
# (See ActiveModel::Name for more 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
|
def model_name
|
||||||
@_model_name ||= begin
|
@_model_name ||= begin
|
||||||
namespace = self.parents.detect do |n|
|
namespace = self.parents.detect do |n|
|
||||||
|
|
Loading…
Reference in a new issue