trying to pass a collection of authors using
<%= render :partial => ''author'', :collection =>
@authors %>
_authors.rhtml file has
<tr>
<td><%= link_to author.name, :action => ''show'',
:id => @author %></
td>
<td><%= link_to ''Edit'', :action =>
''edit'', :id => author %></td>
<td>
<%= button_to ''Delete'', {:action =>
''destroy'', :id => author},
:confirm =>
"Are you sure you want to delete author #{author.name}?"
%>
</td>
</tr>
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: <tr>
2: <td><%= link_to @post.author.name, :action =>
''show'', :id =>
@author %></td>
3: <td><%= link_to ''Edit'', :action =>
''edit'', :id => author %></td>
4: <td>
5: <%= button_to ''Delete'', {:action =>
''destroy'', :id => author},
any ides what I may be doing wrong here ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Dave wrote:> trying to pass a collection of authors using > <%= render :partial => ''author'', :collection => @authors %> > > _authors.rhtml file has > > <tr> > <td><%= link_to author.name, :action => ''show'', :id => @author %></ > td> > <td><%= link_to ''Edit'', :action => ''edit'', :id => author %></td> > <td> > <%= button_to ''Delete'', {:action => ''destroy'', :id => author}, > :confirm => > "Are you sure you want to delete author #{author.name}?" %> > </td> > </tr> > > 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: <tr> > 2: <td><%= link_to @post.author.name, :action => ''show'', :id => > @author %></td> > 3: <td><%= link_to ''Edit'', :action => ''edit'', :id => author %></td> > 4: <td> > 5: <%= button_to ''Delete'', {:action => ''destroy'', :id => author}, > > > any ides what I may be doing wrong here ?Where is @post being set? -- Michael Wang --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
@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: <tr>
2: <td><%= link_to author.name, :action =>
''show'', :id => @author
%></td>
3: <td><%= link_to ''Edit'', :action =>
''edit'', :id => author %></td>
4: <td>
5: <%= button_to ''Delete'', {:action =>
''destroy'', :id => author},
On Aug 9, 7:53 pm, Michael Wang
<rails-u...-JtyympAsP2K7zZZRDBGcUA@public.gmane.org>
wrote:> Dave wrote:
> > trying to pass a collection of authors using
> > <%= render :partial => ''author'', :collection
=> @authors %>
>
> > _authors.rhtml file has
>
> > <tr>
> > <td><%= link_to author.name, :action =>
''show'', :id => @author %></
> > td>
> > <td><%= link_to ''Edit'', :action =>
''edit'', :id => author %></td>
> > <td>
> > <%= button_to ''Delete'', {:action =>
''destroy'', :id => author},
> > :confirm =>
> > "Are you sure you want to delete author
#{author.name}?" %>
> > </td>
> > </tr>
>
> > 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: <tr>
> > 2: <td><%= link_to @post.author.name, :action =>
''show'', :id =>
> > @author %></td>
> > 3: <td><%= link_to ''Edit'', :action =>
''edit'', :id => author %></td>
> > 4: <td>
> > 5: <%= button_to ''Delete'', {:action =>
''destroy'', :id => author},
>
> > any ides what I may be doing wrong here ?
>
> Where is @post being set?
>
> --
> Michael Wang
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Hi! If the partial is called ''author'', then the file must be called ''_author.rhtml'' Andrey On Aug 9, 10:23 pm, Dave <digit...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> @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: <tr> > 2: <td><%= link_to author.name, :action => ''show'', :id => @author > %></td> > 3: <td><%= link_to ''Edit'', :action => ''edit'', :id => author %></td> > 4: <td> > 5: <%= button_to ''Delete'', {:action => ''destroy'', :id => author}, > > On Aug 9, 7:53 pm, Michael Wang <rails-u...-JtyympAsP2K7zZZRDBGcUA@public.gmane.org> wrote: > > > Dave wrote: > > > trying to pass a collection of authors using > > > <%= render :partial => ''author'', :collection => @authors %> > > > > _authors.rhtml file has > > > > <tr> > > > <td><%= link_to author.name, :action => ''show'', :id => @author %></ > > > td> > > > <td><%= link_to ''Edit'', :action => ''edit'', :id => author %></td> > > > <td> > > > <%= button_to ''Delete'', {:action => ''destroy'', :id => author}, > > > :confirm => > > > "Are you sure you want to delete author #{author.name}?" %> > > > </td> > > > </tr> > > > > 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: <tr> > > > 2: <td><%= link_to @post.author.name, :action => ''show'', :id => > > > @author %></td> > > > 3: <td><%= link_to ''Edit'', :action => ''edit'', :id => author %></td> > > > 4: <td> > > > 5: <%= button_to ''Delete'', {:action => ''destroy'', :id => author}, > > > > any ides what I may be doing wrong here ? > > > Where is @post being set? > > > -- > > Michael Wang--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks for the help got it working... On Aug 10, 12:22 am, stitcher <myatl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi! > > If the partial is called ''author'', then the file must be called > ''_author.rhtml'' > > Andrey > > On Aug 9, 10:23 pm, Dave <digit...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > @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: <tr> > > 2: <td><%= link_to author.name, :action => ''show'', :id => @author > > %></td> > > 3: <td><%= link_to ''Edit'', :action => ''edit'', :id => author %></td> > > 4: <td> > > 5: <%= button_to ''Delete'', {:action => ''destroy'', :id => author}, > > > On Aug 9, 7:53 pm, Michael Wang <rails-u...-JtyympAsP2K7zZZRDBGcUA@public.gmane.org> wrote: > > > > Dave wrote: > > > > trying to pass a collection of authors using > > > > <%= render :partial => ''author'', :collection => @authors %> > > > > > _authors.rhtml file has > > > > > <tr> > > > > <td><%= link_to author.name, :action => ''show'', :id => @author %></ > > > > td> > > > > <td><%= link_to ''Edit'', :action => ''edit'', :id => author %></td> > > > > <td> > > > > <%= button_to ''Delete'', {:action => ''destroy'', :id => author}, > > > > :confirm => > > > > "Are you sure you want to delete author #{author.name}?" %> > > > > </td> > > > > </tr> > > > > > 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: <tr> > > > > 2: <td><%= link_to @post.author.name, :action => ''show'', :id => > > > > @author %></td> > > > > 3: <td><%= link_to ''Edit'', :action => ''edit'', :id => author %></td> > > > > 4: <td> > > > > 5: <%= button_to ''Delete'', {:action => ''destroy'', :id => author}, > > > > > any ides what I may be doing wrong here ? > > > > Where is @post being set? > > > > -- > > > Michael Wang--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---