stanley wendo
stanley wendo

Reputation: 65

ruby on rails undefined method `errors' for nil:NilClass

currently working on my project.and
i'm trying to create an existing article page but i keep getting this message undefined method `errors' for nil: Nil Class. currently working on my project Edit existing article

<% [email protected]? %>
<h>The following errors prevented the article from getting created</h>
<ul>
<%@article.errors.full_messages.each do  |msg| %

Upvotes: 0

Views: 181

Answers (1)

Derrell Durrett
Derrell Durrett

Reputation: 576

@article doesn't exist. It's probably expected that your controller is setting this variable, and you haven't done that (or it's failing to get a value for some other reason).

Note that the places errors exists in your code snippet are method calls (x.y implies y is a method on the object x in Ruby). This is how to identify this problem in the future.

Upvotes: 1

Related Questions