NameError?

Hi all,

I’ve created an app that has posts with string “title” and text
“content”.

I’m getting the following error when adding this loop. Any idea?

NameError in Posts#index

Showing /Users/bradwrage/webapps/blog/app/views/posts/index.html.erb
where
line #7 raised:

undefined local variable or method `post’ for
#<#Class:0x10bf2d620:0x10c058798>

Extracted source (around line #7):

4:
5: <% @posts.each do |status| %>
6:


7: <%= post.title %>
8:

9:
10: <% end %>

On Thu, Oct 18, 2012 at 9:38 AM, wragen22 [email protected] wrote:

Extracted source (around line #7):

4:
5: <% @posts.each do |status| %>
6:


7: <%= post.title %>
8:

9:
10: <% end %>

Took me all of 0.00000000000000000000000000000000000000001 seconds to
notice that you have @posts.each o |status| instead of @posts.each do
|post| which means you haven’t even told it that post should be the
variable in that closure, status is the current.

Hello,

Try to change post.title to status.title.

You say that for every post do and name it status.

Roelof

Op donderdag 18 oktober 2012 16:38:03 UTC+2 schreef wragen22 het
volgende:

you loop through all @posts, but your object is called “status” - change
“status” to “post” and everything will work…

Am Donnerstag, 18. Oktober 2012 16:38:03 UTC+2 schrieb wragen22: