rspec 测试未通过此项目:
Failure/Error: before { visit user_path(user) }
ActionView::Template::Error:
undefined method `picking?' for nil:NilClass
触发此错误的代码是:
<% if current_user.picking?(post) %>
在用户模型中,picking方法定义为:defpicking?(post)trips.find_by_pickedpost_id(post.id)end
current_user 定义为:
def current_user=(user)
@current_user = user
end
def current_user
@current_user ||= user_from_remember_token
end
为什么测试失败?为什么 current_user 是零类?