当我在 Rails 应用程序上以管理员身份登录时,我转到管理页面,然后转到Users
activeadmin 中的列(其中包括管理员用户)。当我单击edit
当前登录的管理员用户时,我编辑了字段,然后当我单击时Update User
出现以下错误:
ActiveRecord::RecordNotFound in Admin::UsersController#update
Couldn't find User with id=5 [WHERE ('t'='f')]
这只发生在我为current_user
而不是为任何其他用户执行上述过程时。
这是我的admin/users.rb
文件:
ActiveAdmin.register User do
index do
column :email
column :current_sign_in_at
column :last_sign_in_at
column :sign_in_count
default_actions
end
filter :email
form do |f|
f.inputs "Admin Details" do
f.input :email
f.input :initials
f.input :password
f.input :password_confirmation
end
f.actions
end
end
这是我的user.rb
模型文件:
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_associated_audits
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me ,:name, :initials
has_many :entries
end