Ruby on Rails教程(第4版) 13.55 undefined local variable or method `object'
Mac环境
Rails 5.1.4
ruby 2.4.1
bootstrap v3.3.7
------------------坑区-------------------
Ruby on Rails教程(第4版)
第13章 代码清单 13.55:微博界面的集成测试
rails test过程中出现以下错误
Error: PasswordResetsTest#test_password_resets: ActionView::Template::Error: undefined local variable or method `object' for #<#<Class:0x007fb0ae608b80>:0x007fb0b6aa2be8> Did you mean? object_id app/views/shared/_error_messages.html.erb:1:in `_app_views_shared__error_messages_html_erb__4137229505976994782_70198477753340' app/views/password_resets/edit.html.erb:7:in `block in _app_views_password_resets_edit_html_erb___1570339071004732838_70198477789400' app/views/password_resets/edit.html.erb:6:in `_app_views_password_resets_edit_html_erb___1570339071004732838_70198477789400' test/integration/password_resets_test.rb:36:in `block in <class:PasswordResetsTest>'
----------------------------------------
解决方法:
根据进度做到13.55时,修改以下代码就可以test通过
打开/Users/mac/workspace/sample_app/app/views/password_resets/edit.html.erb
把 , object: f.object 添加到render里就可以处理以上这个错误。
<%= render 'shared/error_messages', object: f.object %>