【发布时间】:2012-05-21 08:15:51
【问题描述】:
rspec 测试未通过此项目:
Failure/Error: before { visit user_path(user) }
ActionView::Template::Error:
undefined method `picking?' for nil:NilClass
触发这个错误的代码是:
<% if current_user.picking?(post) %>
在用户模型中,拣货方式定义为: def 采摘?(帖子) trips.find_by_pickedpost_id(post.id) 结束
current_user 定义为:
def current_user=(user)
@current_user = user
end
def current_user
@current_user ||= user_from_remember_token
end
为什么测试失败?为什么 current_user 是 nil 类?
【问题讨论】:
-
+0。句子以大写字母开头,并且您没有突出显示所有代码。