- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我是 Ruby on Rails 的新手。我正在使用 ActiveAdmin,但在创建 AdminUser 时遇到问题
ActiveModel::AdminUsersController 中的 ForbiddenAttributesError#createActiveModel::ForbiddenAttributesError
hỏi
tham số:
{"utf8"=>"✓",
"authenticity_token"=>"nvV++6GNTdA/nDzw1iJ6Ii84pZPcv2mzg0PK2Cg9Ag0=",
"admin_user"=>{"email"=>"admin2@example.com"},
"commit"=>"创建管理员用户"}*
轨道 4.1.0
activeadmin 1.0.0
ruby 2.1
app/admin/admin_user.rb
ActiveAdmin.register AdminUser do
index do
column :email
column :current_sign_in_at
column :last_sign_in_at
column :sign_in_count
default_actions
kết thúc
form do |f|
f.inputs "Admin Details" do
f.input :email
kết thúc
f.actions
kết thúc
kết thúc
app/models/admin_user.rb
class AdminUser < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable,
:recoverable, :rememberable, :trackable, :validatable
after_create { |admin| admin.send_reset_password_instructions }
def password_required?
new_record? ? false : super
kết thúc
kết thúc
gem 文件
source 'https://rubygems.org'
gem 'rails', '4.1.0'
gem 'sqlite3'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'activeadmin', github: 'gregbell/active_admin'
gem 'polyamorous', github: 'activerecord-hackery/polyamorous'
gem 'ransack', github: 'activerecord-hackery/ransack'
gem 'formtastic', github: 'justinfrench/formtastic'
gem 'devise'
gem 'sdoc', '~> 0.4.0', group: :doc
config/environments/development.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
# 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
# Sending emails works
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
kết thúc
câu trả lời hay nhất
Rails 4
使用强参数,将属性白名单从模型转移到 Controller 。有必要指定您希望保存在数据库中的属性。您不允许代码中的属性,这就是您收到 ActiveModel::ForbiddenAttributesError
的原因。
引用的文档ActiveAdmin : Setting up Strong Parameters
您可以通过以下方式设置强参数,使用 permit_params
方法创建一个名为 permitted_params
的方法,在覆盖 tạo nên
时使用此方法或 gia hạn
操作:
ActiveAdmin.register AdminUser do
## ...
permit_params :attr1, :attr2 ## Add this line
kết thúc
Sẽ :attr1
、:attr2
等替换为您要列入白名单的实际属性名称。例如::email
关于ruby - ActiveAdmin ForbiddenAttributesError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23655366/
我是 Ruby on Rails 的新手。我正在使用 ActiveAdmin,但在创建 AdminUser 时遇到问题 ActiveModel::AdminUsersController 中的 For
我刚刚开始研究 ROR。 我严格按照 ROR 官方文档制作了博客应用程序。 它适用于 CRDU。 现在我向它添加了 Active Admin,它在删除时工作正常,但在创建/更新时出错 引发 Activ
我一直在遵循关于创建和安装引擎的 rails 指南 here .创建博客文章,当我尝试发表评论时,它返回“ActiveModel::ForbiddenAttributesError in Blorgh
我正在使用设计来注册我的用户。我正在自定义注册 Controller 的创建操作,但是每当我尝试创建任何新用户时,它都会被拒绝,并且出现上述错误。我知道我必须允许所需的参数,而且我这样做了,所以我不明
我一直在使用 strong_params 并试图让创建的对象通过。我有两个问题。 您如何找出导致问题的属性? 我在下面的代码中缺少什么? 让我们从错误开始,日志什么也没告诉我。 ActiveModel
我在 Ruby 中有这个模型,但它抛出一个 ActiveModel::ForbiddenAttributesError class User true, :uniqueness => true, :
当使用 strong_params 并获得 ActiveModel::ForbiddenAttributesError 时异常(exception),我如何找出哪个属性被禁止?我刚从 attr_acc
我看过瑞恩铁路广播第 274 集 我正在使用 rails 4 并遇到一个问题。 在 password_resets_controller.rb elsif @user.update_attribute
我有点失落。我收到 Rails 4 错误:ActiveModel::ForbiddenAttributesError。我知道这意味着我需要允许项目通过,我已经做到了,但我一定遗漏了一些东西。 评论 C
这个问题在这里已经有了答案: ActiveModel::ForbiddenAttributesError when creating new user (7 个回答) 7年前关闭。 我尝试使用 rai
我在 Rails 4 中遇到 ForbiddenAttributesError 下面是我的请求参数 Request parameters {"utf8"=>"✓", "authenticity_to
我有一个使用 Grape 的 ruby 应用程序,但它没有 Rails。 class Article 4.0.0" app.rb require 'rack/test' require 'act
在我的应用程序中,我决定将部分逻辑移到名为 CategoryForm 的额外类中,该类专用于 ActiveRecord Category 类。不幸的是,当我将参数传递到 Category 时,引发了
我的 Rails 4 应用程序中出现“ForbiddenAttributesError”。我在这里缺少什么? 还有一个问题是,为什么没有将“examination_id”参数发送到请求中? 请求 St
我似乎找不到问题所在。在我的 Admin::CompetitionsController 'edit' } end end end d
我正致力于将遗留应用程序升级到 Rails 4,但我遇到了无法解释的(至少对我而言)ForbiddenAttributesError。 在使用它们创建 Station 的新实例之前,我已经将参数列入白
我有一个评论 Controller 和一个产品 Controller 。它在注释 Controller 的创建操作上失败,并出现禁止属性错误。 我已经从模型中删除了所有的 attr_accessibl
所以我在这里浏览了 Rails 教程: http://ruby.railstutorial.org/ruby-on-rails-tutorial-book 并试图让 ActiveAdmin 能够删除用
我想要什么: 我在 View 中需要一个按钮或链接(这无关紧要)到 Reservation 的create 操作 Controller 并给它一个参数。 并解决现在给我的 ForbiddenAttri
我已经开始学习 Ruby on Rails。 我遇到以下错误:ActiveModel::ForbiddenAttributesError in PostsController#create 代码如下:
Tôi là một lập trình viên xuất sắc, rất giỏi!