I'm working through the railtutorial.org online book for rails 3.
I've made it through most of chapter 11, where we add the ability to submit a micropost. After adding the appropriate code, I'm unable to render the page. The following is the error returned:
>
NoMethodError in Pages#home
Showing c:/rails_projects/sample_app/app/views/shared/_error_messages.html.erb where line >#1 raised:
You have a nil object when you didn't expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.errors Extracted source (around line #1):
1:
<% if @user.errors.any? %>
2:<div id="error_explanation">
3:<h2><%= pluralize(@user.errors.count, "error") %>
4:prohibited this <%= object.class.to_s.underscore.humanize.downcase %>
Trace of template inclusion: app/views/shared/_micropost_form.html.erb, >app/views/pages/home.html.erb
The page will render correctly if I remove the following line from app\views\shared_micropost_form.html.erb <%= render 'shared/error_messages', :object => f.object %>
Any help is appreciated.