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 *
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_path(category) %>


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

Can anyone help? Thanks!

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

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

Then I changed to this:

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


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs