【问题标题】:Rails 4 Active Admin ProblemsRails 4 活动管理员问题
【发布时间】:2016-01-02 16:13:55
【问题描述】:

我在使用 Active Admin 时遇到了两个大问题

当我去编辑用户时,加密密码不会显示,所以基本上我不得不破解我自己的网站并将另一个加密密码复制并粘贴到该字段中以更新用户 - 这与创建用户相同.

第二个问题是我无法创建新用户。当我去创建用户时,什么也没有发生。我没有收到错误。页面只是刷新,用户没有保存。

用户.rb

ActiveAdmin.register User do

controller do
    def permitted_params
      params.permit! 
    end
  end

end

我尝试破坏我安装的活动管理员,然后我重新安装它并再次生成模型,但结果相同。我正在使用 Rails 4.2.1 和 Ruby 2.0.0。

gem 'activeadmin', github: 'activeadmin'

开发中.rb

Rails.application.configure do
  # Settings specified here will take precedence over those in config/application.rb.

  # In the development environment your application's code is reloaded on
  # every request. This slows down response time but is perfect for development
  # since you don't have to restart the web server when you make code changes.
  config.cache_classes = false

  # Do not eager load code on boot.
  config.eager_load = false

  # Show full error reports and disable caching.
  config.consider_all_requests_local = true
  config.action_controller.perform_caching = false

  # Don't care if the mailer can't send.
  config.action_mailer.raise_delivery_errors = false

  # Print deprecation notices to the Rails logger.
  config.active_support.deprecation = :log

  # Raise an error on page load if there are pending migrations.
  config.active_record.migration_error = :page_load

  # Debug mode disables concatenation and preprocessing of assets.
  # This option may cause significant delays in view rendering with a large
  # number of complex assets.
  config.assets.debug = true

  # Asset digests allow you to set far-future HTTP expiration dates on all assets,
  # yet still be able to expire them through the digest params.
  config.assets.digest = true

  # Adds additional error checking when serving assets at runtime.
  # Checks for improperly declared sprockets dependencies.
  # Raises helpful error messages.
  config.assets.raise_runtime_errors = true

  # Raises error for missing translations
  # config.action_view.raise_on_missing_translations = true
end

我尝试将 config.cache_classes = false 更改为 true,但这也不起作用。

我不确定在这里做什么。有什么建议么?我认为这是一个错误。希望它可以修复。谢谢。

【问题讨论】:

    标签: ruby-on-rails activeadmin


    【解决方案1】:

    您的 app/admin/user.rb 文件中的 allowed_pa​​rams 方法似乎是非常规的,可能会给您带来问题。您需要像这样添加它们并输入 :encrypted_pa​​ssword 如果您希望能够更改/编辑它...

    ActiveAdmin.register User do
      permit_params :email, :password, :password_confirmation, :encrypted_password
      ...
    end
    

    【讨论】:

    • 这不起作用。我不认为这是正确的语法。 WRT加密的密码它没有编辑它是问题 - 它是在编辑用户时它没有显示在字段中,这意味着我必须复制并粘贴另一个用户的密码才能更新用户。谢谢。
    • ActiveAdmin.register User do permit_params :email, :full_name, :encrypted_pa​​ssword, :admin end 我需要在这里定义 create 还是 new 吗?
    猜你喜欢
    • 2013-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-23
    • 1970-01-01
    • 2017-01-04
    • 2015-11-07
    • 1970-01-01
    相关资源
    最近更新 更多