def can_save(board,role)
if ar_user = already_registered?(email) || user = self.save
Participant.make(ar_user||user, board, role)
end
user
end
我在上面做了这个rspec测试:
it "should return the user if the user is not already registered" do
lambda do
user = @new_user.can_save(@board, "Manager")
end.should change(User,:count).by(1)
end
我收到此错误:
undefined method `id' for true:TrueClass
为什么?
答案 0 :(得分:8)
save
方法返回true或false,而不是保存的对象实例。