モデルで属性応答をテストしています。
it { should respond_to(:password) }
it { should respond_to(:password_confirmation) }
これらの属性はデータベースの一部ではありませんが、私のモデルでは単にとして宣言されていattr_accessible
ます。それらを宣言せずにテストを実行すると、次のようになります。
ActiveModel::MassAssignmentSecurity::Error:
Can't mass-assign protected attributes: password, password_confirmation
しかし、私がそれらを宣言した後、私は得ます:
ActiveRecord::UnknownAttributeError:
unknown attribute: password
なぜこれが起こるのか考えていますか?