2
我正在阅读documentation of Factory Girl并遇到此代码块。关于FactoryGirl的问题
#The behavior of the association method varies depending on the build strategy used for the parent object.
#Builds and saves a User and a Post
post = FactoryGirl.create(:post)
post.new_record? # => false
post.author.new_record # => false
# Builds and saves a User, and then builds but does not save a Post
post = FactoryGirl.build(:post)
post.new_record? # => true
post.author.new_record # => false
我是新工厂女孩,但应该不是第一个代码示例new_record返回true?我很困惑,为什么它会返回false,如果这个帖子是建立和保存的。
啊。我懂了。这是一个相当混乱的术语,所以我很高兴它已被弃用。我想他们还没有到处去更新文档。 http://api.rubyonrails.org/classes/ActiveRecord/Base.html – picardo 2011-03-19 15:03:33