1

Ruby 1.9.3 上の Rails 3.2.13 から Rails 4.0.0 へのアップグレード。

Devise 3.0.0.rc は一括割り当てしません。ここで説明する両方のアプローチから始めて、私が見つけたすべての提案に従いました: https://github.com/plataformatec/devise#strong-parameters

ログイン/ログアウトは機能しますが、登録は機能しません:

Started POST "/users" for 127.0.0.1 at 2013-07-03 21:01:47 -0500
Processing by RegistrationsController#create as HTML
Parameters: {"utf8"=>"✓", 
"authenticity_token"=>"5QPwkbXULEsF5nCiMMK7zd04baZ5kOecgqV2BdRnSEc=", 
"user"=>{"first_name"=>"test", "last_name"=>"testor", "email"=>"asdhd@gmail.com",
"username"=>"testy", "password"=>"[FILTERED]", 
"password_confirmation"=>"[FILTERED]"}, "commit"=>"Register"}
WARNING: Can't mass-assign protected attributes for User: email, password, 
password_confirmation, first_name, last_name, username

これはDeviseの問題ですか?誰にも解決策がありますか?

ありがとう!

4

2 に答える 2

2

問題は、レールキャストhttp://railscasts.com/episodes/415-upgrading-to-rails-4に従って使用した gem 'protected_attributes' でした。

...
# add these gems to help with the transition:
gem 'protected_attributes'
...

gem が params.require(:incoming_model).permit( .... ) のような Rails 4 メソッドを妨害するとは思いもしませんでした。誤解していたかもしれません。

宝石を取り除くと、問題が解消されます。ここで言及されている最初のアプローチ (怠惰な方法) は機能します: https://github.com/plataformatec/devise#strong-parameters

于 2013-07-04T04:34:44.320 に答える
0

application.rbでconfig.active_record.whitelist_attributesを false に設定します。

include ActiveModel::ForbiddenAttributesProtectionをモデルに追加します

以下をご覧ください: http://blog.remarkablelabs.com/2012/12/strong-parameters-rails-4-countdown-to-2013

于 2013-07-04T02:08:47.510 に答える