Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Introspection using ActiveModel

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 234
    Comment on it

    ActiveModel is a library which contains various modules which when added to a class add some features present on Active Record to the class. One such module is ActiveModel::Naming module. This module is used for model name introspection .Below are the methods of this module:

    class User
      extend ActiveModel::Naming
    end
    
    User.model_name.name                # => "User"
    User.model_name.singular            # => "user"
    User.model_name.plural              # => "users"
    User.model_name.element             # => "user"
    User.model_name.human               # => "User"
    User.model_name.collection          # => "users"
    User.model_name.param_key           # => "users"
    User.model_name.i18n_key            # => :user
    User.model_name.route_key           # => "users"
    User.model_name.singular_route_key  # => "user"
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: