singular_route_key

singular_route_key(record_or_class) Class Public methods Returns string to use while generating route names. It differs for namespaced models regarding whether it's inside isolated engine. # For isolated engine: ActiveModel::Naming.singular_route_key(Blog::Post) # => "post" # For shared engine: ActiveModel::Naming.singular_route_key(Blog::Post) # => "blog_post"

singular

singular(record_or_class) Class Public methods Returns the singular class name of a record or class. ActiveModel::Naming.singular(post) # => "post" ActiveModel::Naming.singular(Highrise::Person) # => "highrise_person"

route_key

route_key(record_or_class) Class Public methods Returns string to use while generating route names. It differs for namespaced models regarding whether it's inside isolated engine. # For isolated engine: ActiveModel::Naming.route_key(Blog::Post) # => "posts" # For shared engine: ActiveModel::Naming.route_key(Blog::Post) # => "blog_posts" The route key also considers if the noun is uncountable and, in such cases, automatically appends _index.

plural

plural(record_or_class) Class Public methods Returns the plural class name of a record or class. ActiveModel::Naming.plural(post) # => "posts" ActiveModel::Naming.plural(Highrise::Person) # => "highrise_people"

param_key

param_key(record_or_class) Class Public methods Returns string to use for params names. It differs for namespaced models regarding whether it's inside isolated engine. # For isolated engine: ActiveModel::Naming.param_key(Blog::Post) # => "post" # For shared engine: ActiveModel::Naming.param_key(Blog::Post) # => "blog_post"

to_str

to_str() Instance Public methods Equivalent to to_s.

to_s

to_s() Instance Public methods Returns the class name. class BlogPost extend ActiveModel::Naming end BlogPost.model_name.to_s # => "BlogPost"

human

human(options={}) Instance Public methods Transform the model name into a more humane format, using I18n. By default, it will underscore then humanize the class name. class BlogPost extend ActiveModel::Naming end BlogPost.model_name.human # => "Blog post" Specify options with additional translating options.

eql?

eql?(other) Instance Public methods Equivalent to String#eql?. Returns true if the class name and other have the same length and content, otherwise false. class BlogPost extend ActiveModel::Naming end BlogPost.model_name.eql?('BlogPost') # => true BlogPost.model_name.eql?('Blog Post') # => false

=~

=~(regexp) Instance Public methods Equivalent to String#=~. Match the class name against the given regexp. Returns the position where the match starts or nil if there is no match. class BlogPost extend ActiveModel::Naming end BlogPost.model_name =~ /Post/ # => 4 BlogPost.model_name =~ /\d/ # => nil