NoMethodError

I am receiving this error messagek

NoMethodError in Story#index

Showing app/views/story/index.rhtml where line #2 raised:

You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.size
Extracted source (around line #2):

1:


2: <%= “Showing #{ pluralize(@stories.size, ‘story’, ‘stories’) }”
%>
3:


4: <%= render :partial => ‘story’, :collection => @stories %>

Any help would be appreciated. Thanks.

Zkidd wrote:

I am receiving this error messagek

NoMethodError in Story#index

Showing app/views/story/index.rhtml where line #2 raised:

You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.size
Extracted source (around line #2):

1:


2: <%= “Showing #{ pluralize(@stories.size, ‘story’, ‘stories’) }”
%>
3:


4: <%= render :partial => ‘story’, :collection => @stories %>

Any help would be appreciated. Thanks.

Your @stories instance variable is nil, meaning it doesn’t exist or has
no data in it. In your story controller index method, are you creating
the instance variable called @stories?

Zkidd wrote:

1:


2: <%= “Showing #{ pluralize(@stories.size, ‘story’, ‘stories’) }”
%>
3:


4: <%= render :partial => ‘story’, :collection => @stories %>

Any help would be appreciated. Thanks.

@stories is nil. Make sure the query or whatever object that variable is
pointing at is not nil.


Michael W.