dave
1
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
3
@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}, |
dave
4
Thanks for the help got it working…
dave
5
Hi!
If the partial is called ‘author’, then the file must be called
‘_author.rhtml’
Andrey