Fix is :
<% @allposts.each do |posts, slots| %>
<% slots.each do |post| %> # <--- see I removed @ symbol
<%= post.Title %>
<% end %>
<% end %>
Your block variable is slots
, and you attempted as @slots
. Which I think is a typo. As there is no such @slots
variable defined, you got nil
, when you wanted to use it. There is a sweet difference between local variable and instance variable. If you don't defined anywhere a local variable say foo
, you will be ended up with undefined local variable or method if you want to use foo
anywhere else.But for instance variable, no error, you will silently get nil
.