Nil object where not expected

trying to pass a collection of authors using
<%= render :partial => ‘author’, :collection => @authors %>

_authors.rhtml file has

<%= link_to author.name, :action => 'show', :id => @author %> <%= link_to 'Edit', :action => 'edit', :id => author %> <%= button_to 'Delete', {:action => 'destroy', :id => author}, :confirm => "Are you sure you want to delete author #{author.name}?" %>

in
def index
@authors = Author.find(:all)
@page_title = ‘Listing authors’
end

and I’m getting

You have a nil object when you didn’t expect it!
The error occurred while evaluating nil.author

Extracted source (around line #2):

1:


2: <%= link_to @post.author.name, :action => ‘show’, :id =>
@author %>
3: <%= link_to ‘Edit’, :action => ‘edit’, :id => author %>
4:
5: <%= button_to ‘Delete’, {:action => ‘destroy’, :id => author},

any ides what I may be doing wrong here ?

Dave wrote:

<%= button_to 'Delete', {:action => 'destroy', :id => author},

3:

<%= link_to ‘Edit’, :action => ‘edit’, :id => author %>
4:
5: <%= button_to ‘Delete’, {:action => ‘destroy’, :id => author},

any ides what I may be doing wrong here ?

Where is @post being set?


Michael W.

@post is not being set, I’m a rails newbie @post was one of the
solutions I found on google, but none are solving my problem this the
error I get

You have a nil object when you didn’t expect it!
The error occurred while evaluating nil.name

Extracted source (around line #2):

1:


2: <%= link_to author.name, :action => ‘show’, :id => @author
%>
3: <%= link_to ‘Edit’, :action => ‘edit’, :id => author %>
4:
5: <%= button_to ‘Delete’, {:action => ‘destroy’, :id => author},

Thanks for the help got it working…

Hi!

If the partial is called ‘author’, then the file must be called
‘_author.rhtml’

Andrey