【发布时间】:2012-08-19 08:13:58
【问题描述】:
我正在测试我的模型中的属性响应:
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
知道为什么会这样吗?
【问题讨论】:
-
你选错了答案 =/
标签: ruby-on-rails ruby rspec attr-accessible