【问题标题】:ActiveAdmin: ActiveRecord::RecordNotFound in Admin::UsersController#show when editing current userActiveAdmin: ActiveRecord::RecordNotFound in Admin::UsersController#show when editing current user
【发布时间】:2013-09-13 00:06:41
【问题描述】:

当我在 Rails 应用程序上以管理员身份登录时,我会转到管理页面,然后转到 activeadmin 中的 Users 列(其中包括管理员用户)。当我为当前登录的管理员用户单击 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

【问题讨论】:

  • 因为't'永远不会是'f'。
  • 这个项目是什么版本的 Rails?您是否尝试过删除 has_associated_audits?

标签: ruby-on-rails-3 activeadmin


【解决方案1】:

[WHERE ('t'='f')] 条件永远不会为真!

【讨论】:

  • @Ov3rc10ck3d 是的,但为什么连数据库查询都这样?
  • 显然我没有写那个 SQL 查询:)。
猜你喜欢
  • 1970-01-01
  • 2018-01-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多