加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – rails 3测试用例error.on(:field)vs.错误[:

发布时间:2020-12-17 01:54:02 所属栏目:百科 来源:网络整理
导读:我正在研究Rails 3测试用例.在撰写案例的同时,我得到了贬值错误 DEPRECATION WARNING: Errors#on have been deprecated,use Errors#[] instead.Also note that the behaviour of Errors#[] has changed. Errors#[] now always returns an Array. An empty Ar
我正在研究Rails 3测试用例.在撰写案例的同时,我得到了贬值错误

DEPRECATION WARNING: Errors#on have been deprecated,use Errors#[] instead.
Also note that the behaviour of Errors#[] has changed. Errors#[] now always returns an Array. An empty Array is returned when there are no errors on the specified attribute. (called from on at /usr/local/lib/ruby/gems/1.9.1/gems/activemodel-3.0.0.rc/lib/active_model/deprecated_error_methods.rb:7)

为此我使用了错误[:field]而不是errors.on(:field)
现在,弃用错误已经消失,但是案例在早期工作时没有起作用.它没有测试模型的任何验证

索尔

解决方法

更换:

errors.on(:field)

有:

errors.include?(:field)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读