NilClass in my partial

Hello everyone, in my Rails 3.0.4 app, I created a partial called _category.html.erb that makes part of the category scope of the app like categories_controller, category.rb (the model) and so on. But, when I do render the partial in app/views/categories/index.html.erb it shows the following error:

NoMethodError in Categories#index

Showing /Users/saulolopes/code/parla/app/views/categories/_category.html.erb where line #1 raised:

undefined method `css' for nil:NilClass

Extracted source (around line #1):

1: <li class="<%= "category-#{category.css}"%>">
2: <%= link_to image_tag(category.picture_file_name), category_path(category) %>
3: <p class="<%= "category-title cat-#{category.css}"%>"><%= link_to category.name, category_path(category) %></p>
4: </li>

I am using Inherited Resources in my CategoriesController but I don’t think it’s actually causing any error.

Can anyone help? Thanks!

Hello everyone, I just solve this problem. I had in my partial the following code:

<%= render :partial => “category” -%>

Then I changed to this:

<%= render :partial => “category”, :collection => @categories -%>

Thanks!