登录我的Rails应用程序的activeadmin面板后,我无法创建用户或帖子。我有一个非常简单的自定义Devise注册控制器处理注册:
class Users::RegistrationsController < Devise::RegistrationsController
def create
@user = User.new(sign_up_params)
respond_to do |format|
if @user.save
UserMailer.new_user(@user).deliver_now
AdminMailer.new_user_waiting_for_approval(@user).deliver_now
format.html { redirect_to root_path }
flash[:success] = "You're signed up! We'll notify you when your account has been approved."
else
redirect_to root_path
end
end
end
private
def sign_up_params
params.require(:user).permit(:firstname, :lastname, :email, :password, :password_confirmation)
end
end
这是我的AdminUser模型:
class AdminUser < ActiveRecord::Base
devise :database_authenticatable,
:recoverable, :rememberable, :trackable, :validatable
after_create { |admin| admin.send_reset_password_instructions }
def password_required?
new_record? ? false : super
end
end
当我点击保存时,页面重新加载输入的数据仍然完好无损。控制台读数是:
Started POST "/admin/users" for ::1 at 2017-03-21 09:25:22 -0700
Processing by Admin::UsersController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"LpGfS1Y+241vEIRQ+TW78SzM/+J7GnjRHAyt7Ll0ez4WYWc60/HpODJOsVg0spmpd1haTpSiNxQHOJfZlMh+sA==", "user"=>{"email"=>"j@h.com", "encrypted_password"=>"[FILTERED]", "reset_password_token"=>"[FILTERED]", "reset_password_sent_at(1i)"=>"[FILTERED]", "reset_password_sent_at(2i)"=>"[FILTERED]", "reset_password_sent_at(3i)"=>"[FILTERED]", "reset_password_sent_at(4i)"=>"[FILTERED]", "reset_password_sent_at(5i)"=>"[FILTERED]", "remember_created_at(1i)"=>"", "remember_created_at(2i)"=>"", "remember_created_at(3i)"=>"", "remember_created_at(4i)"=>"", "remember_created_at(5i)"=>"", "current_sign_in_at(1i)"=>"", "current_sign_in_at(2i)"=>"", "current_sign_in_at(3i)"=>"", "current_sign_in_at(4i)"=>"", "current_sign_in_at(5i)"=>"", "last_sign_in_at(1i)"=>"", "last_sign_in_at(2i)"=>"", "last_sign_in_at(3i)"=>"", "last_sign_in_at(4i)"=>"", "last_sign_in_at(5i)"=>"", "current_sign_in_ip"=>"", "last_sign_in_ip"=>"", "firstname"=>"a", "lastname"=>"b", "provider"=>"", "uid"=>"", "oauth_token"=>"", "approved"=>"0", "website"=>"i.com", "is_admin"=>"0"}, "commit"=>"Create User"}
Unpermitted parameters: encrypted_password, reset_password_token, reset_password_sent_at(1i), reset_password_sent_at(2i), reset_password_sent_at(3i), reset_password_sent_at(4i), reset_password_sent_at(5i), remember_created_at(1i), remember_created_at(2i), remember_created_at(3i), remember_created_at(4i), remember_created_at(5i), current_sign_in_at(1i), current_sign_in_at(2i), current_sign_in_at(3i), current_sign_in_at(4i), current_sign_in_at(5i), last_sign_in_at(1i), last_sign_in_at(2i), last_sign_in_at(3i), last_sign_in_at(4i), last_sign_in_at(5i), current_sign_in_ip, last_sign_in_ip, provider, uid, oauth_token
(0.3ms) BEGIN
User Exists (0.5ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = 'j@h.com' LIMIT 1
User Exists (0.4ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = 'j@h.com' LIMIT 1
(0.2ms) ROLLBACK
AdminUser Load (0.3ms) SELECT "admin_users".* FROM "admin_users" WHERE "admin_users"."id" = $1 ORDER BY "admin_users"."id" ASC LIMIT 1 [["id", 2]]
Rendered /Users/mkeable/.rvm/gems/ruby-2.3.0/bundler/gems/activeadmin-85ab3f5961e1/app/views/active_admin/resource/new.html.arb (297.8ms)
Completed 200 OK in 312ms (Views: 304.5ms | ActiveRecord: 1.7ms)
为什么我会得到两个User Exists
?确定用户不存在。