我正在使用Factory_girl
Factory.sequence :name do |n| “name-#{n}” end
Factory.define :user do |u| u.first_name{ Factory.next(:name) }
u.last_name { |u| ‘last_’ + u.first_name } u.password ‘secret’
u.password_confirmation { |u| u.password } u.sequence(:email) { |i|
“user_#{i}@example.com” }end
和这个简单的测试
specify { Factory.build(:user).should be_valid }
生成以下警告
DEPRECATION WARNING: You’re trying to create an attribute
user_id'.
attr_writer` etc. (called from block (2 levels) in
Writing arbitrary attributes on a model is deprecated. Please just use
at…
我该如何摆脱呢?
解决方法
运行rake db:test:准备确保更新.
该方法的Here’s the source code,您可以在其中首先看到Rails检查列或属性,然后警告是否找不到.
原文地址:https://www.jb51.cc/ruby/273431.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。