当我在rails应用程序中以管理员身份登录时,我会转到管理页面,然后转到activeadmin中的Users
列(其中包括管理员用户)。当我为当前登录的admin-user单击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
答案 0 :(得分:1)
[WHERE('t'='f')]条件永远不会成真!