ActiveModel::AttributeMethods
module ActiveModel::AttributeMethods
Active Model Attribute Methods
Provides a way to add prefixes and suffixes to your methods as well as handling the creation of ActiveRecord::Base
-like class methods such as table_name
.
The requirements to implement ActiveModel::AttributeMethods
are to:
-
include ActiveModel::AttributeMethods
in your class. -
Call each of its methods you want to add, such as
attribute_method_suffix
orattribute_method_prefix
. -
Call
define_attribute_methods
after the other methods are called. -
Define the various generic
_attribute
methods that you have declared. -
Define an
attributes登录查看完整内容