"undefined method `errors' for nil:NilClass" when calling on errors method
You need to define @post
in your new
action too.
def new
@post = Post.new
end
You're getting the NilClass
error because @post
has no value (it's nil
) when you first load the form on the new
action.
When you do the render :new
in your create
action there is no problem because it's using the @post
you've defined at the top of create
.