When attr_accessible is created, the Model contains attr_accessible. The full name is attibutes accessible, which literally means that attributes can be accessed, for example, rails g model User name: string email: string, the following files are created and automatically added to attr_accessible class User <ActiveRecord: Base attr_accessible: name,: emailendend. If there is no attr_accessible, access is disabled by default. This is a security mechanism. validates verification validates_presence_of, expires, expires, allow_nil, allow_blank, message, onRails3 after validates: email,: presence => true,: length =>{: minimum => 3 ,: maximum => 254,: message => "incorrect length"},: uniqueness => true,: email => true validate: my_validation errors [: base] <"can not be xxx" attr_reader and attr_accessor are mainly used to set or read attribute values in the class. attr_reader is read-only and cannot be set, while attr_accessor can be read. You can also set cattr_accessorcattr_accessor, which is equivalent to static variables of java classes and shared with all class instances.