创建新用户时ActiveModel :: ForbiddenAttributesError
我在Ruby中有这个模型,但是它抛出了一个 ActiveModel::ForbiddenAttributesError class User < ActiveRecord::Base attr_accessor :password validates :username, :presence => true, :uniqueness => true, :length => {:in => 3..20} VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i validates :email, presence: true, :uniqueness => true, format: { with: VALID_EMAIL_REGEX } validates :password, :confirmation => true validates_length_of :password, :in => 6..20, :on => :create before_save …