0
我知道這已被問過一百萬次,但建議的解決方案並沒有解決任何問題。UsersController中的ActiveModel :: ForbiddenAttributesError#創建
def create
@user = User.new(user_params)
if @user.save
else
render 'new'
end
end
起初,我有這些PARAMS:
private
def user_params
params.require(:user).permit(:firstname, :name, :email, :password,
:password_confirmation, role_ids: [])
end
然後我試圖讓每PARAM:
private
def user_params
params.require(:user).permit!
end
然而,結果是一樣的:
::加載ActiveModel UsersController中的ForbiddenAttributesError#create
def sanitize_for_mass_assignment(attributes)
if attributes.respond_to?(:permitted?) && !attributes.permitted?
raise ActiveModel::ForbiddenAttributesError
else
attributes
end
我錯過了什麼?
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
Rails 4.2.2