我正在使用 Rails 4 和 Devise 3。我添加了一个自定义字段“名称”。当我提交名称时,我收到“不允许的参数:名称”和“无法为用户批量分配受保护的属性:电子邮件”错误。
我被告知要向用户控制器添加代码,但是 Devise 没有创建一个。我应该自己创建一个 users_controller.rb,还是我在这里遗漏了什么?
我的用户模型如下所示:
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, #:recoverable,
:rememberable, :trackable, :validatable
#attr_accessible :name, :password, :password_confirmation, :remember_me, :email
end
如您所见,我尝试使用 attr_accessible,但由于 Rails 4 不支持它而将其注释掉。