I am creating a blog to learn ruby on rails. The blog.rhtml in the
layout folder has a the following code
The content in the middle td displaying the posts is working fine. In
the right td i want to display all the categories. I can get the
template to render to the right column with just html but i cant display
any of the categories when i add the ruby code to display them. The
code for the _categorylist.rhtml is below.
<% for category in @categories %>
<%= category.name %>
<% end %>
I keep getting the following error below:
You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.each
What is the problem? I have used similar code to get the posts working
but cant seem to get this to work. Am i missing something in the blog
controller. At the moment i have the following code in the
@categories = Category.find(:all)
Can anyone help please!