我在注册新用户(使用设计进行身份验证)时收到消息未经许可的参数:电子邮件
Started POST "/users" for 127.0.0.1 at 2017-01-10 00:19:01 +0200
Processing by Devise::RegistrationsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"omU3TFsQ5lG3SIvD7qSBi07VZywtL2EKIbTVn2q/Qt2PecCZvX6rlSEEiNg9yRPYgkDBkUDLbA59gJyUmQQNhA==", "user"=>{"username"=>"x", "email"=>"x@example.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Sign up"}
Unpermitted parameter: email
(0.3ms) begin transaction
(0.0ms) rollback transaction
Rendered devise/shared/_links.html.erb (0.2ms)
Rendered users/registrations/new.html.erb within layouts/application (4.9ms)
Rendered layouts/_header.html.erb (0.6ms)
Rendered layouts/_messages.html.erb (0.1ms)
Rendered shared/_search.html.erb (0.1ms)
Rendered layouts/_footer.html.erb (0.1ms)
Completed 200 OK in 253ms (Views: 137.6ms | ActiveRecord: 1.1ms)
我正在使用 activeadmin gem进行管理(使用devise for Admin_user),我正在使用另一个模型(用户)的设计。我已覆盖用户注册控制器,如下所示:
class Users::RegistrationsController < Devise::RegistrationsController
before_filter :configure_sign_up_params, only: [:create]
before_filter :configure_account_update_params, only: [:update]
...
protected
# If you have extra params to permit, append them to the sanitizer.
def configure_sign_up_params
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:username, :email ,:password, :password_confirmation) }
end
# If you have extra params to permit, append them to the sanitizer.
def configure_account_update_params
devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:username, :email, :current_password ,:password, :password_confirmation) }
end
end
我不知道我错过了什么!