ActiveModel :: ForbiddenAttributesError即使在我将所有属性添加到强参数时也会显示

时间:2014-12-04 02:18:52

标签: ruby-on-rails activeadmin

我的应用程序出现此错误。

::加载ActiveModel ForbiddenAttributesError

我正在使用 gem'activeadmin',github:'activeadmin',gem'trail','4.1.7'

即使所有列出的属性都包含在我的Active Admin Model上的强参数中。

模型

ActiveAdmin.register User do

permit_params = :prefix, :firstname, :lastname, :password, :email, :membership_code, :birthdate, :contact_number, :location, :active, :confirmed, :remember_token, :town, :province

错误

Request

Parameters:

{"utf8"=>"✓",
 "authenticity_token"=>"xVA04SdSTDLrwC088FCTRm9fr62z+fgs6wJc0yNn/NU=",
 "user"=>{"prefix"=>"mzxklmcklzmklMAKMDAKLSDMASKLDM",
 "firstname"=>"KLMSDKMSADKLAMS",
 "lastname"=>"MKDSMFKSLDMFK",
 "password"=>"[FILTERED]",
 "email"=>"KLMFDKDSMFKLSDMFKL",
 "membership_code"=>"MKDFSMKLSDMFK",
 "birthdate(1i)"=>"2009",
 "birthdate(2i)"=>"2",
 "birthdate(3i)"=>"1",
 "contact_number"=>";WE,
LA;SD,
",
 "location"=>",
LDSF,
LSDF,
SL;",
 "active"=>"1",
 "confirmed"=>"1",
 "remember_token"=>"DSL;FSDFL",
 "town"=>"FDMSKLFM",
 "province"=>"FMSDFLKS"},
 "commit"=>"Create User"}

任何帮助?

已更新

起初,我认为这是导致错误的生日(它包含3个参数,而不是1) 但我也有一个不同的资源,其中也有生日,它实际上有效。

1 个答案:

答案 0 :(得分:0)

我在permit_params宣言上写了一个错字。我刚删除了等号。

错误:

permit_params = :prefix, :firstname, :lastname, :password, :email, :membership_code, :birthdate, :contact_number, :location, :active, :confirmed, :remember_token, :town, :province

右:

permit_params :prefix, :firstname, :lastname, :password, :email, :membership_code, :birthdate, :contact_number, :location, :active, :confirmed, :remember_token, :town, :province

谢谢! @nistvan