I''ve got a list of members in a sidebar using the code below. It works great for the list page, but when I edit or add a new member I get "You have a nil object when you didn''t expect it!" - I have a hunch this is just a nooby mistake, but I''m at a loss. Any help would be greatly appreciated! <% for member in @members %> <li><%= link_to h(member.first_name) + " " + h(member.last_name), edit_member_path(player) %></li> <% end %> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Kedron - On 31-Aug-07, at 10:27 PM, Kedron wrote:> > I''ve got a list of members in a sidebar using the code below. It works > great for the list page, but when I edit or add a new member I get > "You have a nil object when you didn''t expect it!" - I have a hunch > this is just a nooby mistake, but I''m at a loss. Any help would be > greatly appreciated! > > <% for member in @members %> > <li><%= link_to h(member.first_name) + " " + h(member.last_name), > edit_member_path(player) %></li> > <% end %> >Your log file will tell you more - like the line number (it''s a stack trace). generally one of your variables is a nil. The line number should help. You could try logging the values out. Some people would use the built in debugger to help out. cheers, Jodi --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Aug 31, 10:32 pm, Jodi Showers <j...-BOB1p6JRLoAV+D8aMU/kSg@public.gmane.org> wrote:> Kedron - > > On 31-Aug-07, at 10:27 PM, Kedron wrote: > > > > > I''ve got a list of members in a sidebar using the code below. It works > > great for the list page, but when I edit or add a new member I get > > "You have a nil object when you didn''t expect it!" - I have a hunch > > this is just a nooby mistake, but I''m at a loss. Any help would be > > greatly appreciated! > > > <% for member in @members %> > > <li><%= link_to h(member.first_name) + " " + h(member.last_name), > > edit_member_path(player) %></li> > > <% end %> > > Your log file will tell you more - like the line number (it''s a stack > trace). > > generally one of your variables is a nil. The line number should help. > > You could try logging the values out. Some people would use the built > in debugger to help out. > > cheers, > JodiThanks Jodi for the quick response! The log says its the first line: <% for player in @players %> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Kedron - On 31-Aug-07, at 10:44 PM, Kedron wrote:> > > > On Aug 31, 10:32 pm, Jodi Showers <j...-BOB1p6JRLoAV+D8aMU/kSg@public.gmane.org> wrote: >> Kedron - >> >> On 31-Aug-07, at 10:27 PM, Kedron wrote: >> >> >> >>> I''ve got a list of members in a sidebar using the code below. It >>> works >>> great for the list page, but when I edit or add a new member I get >>> "You have a nil object when you didn''t expect it!" - I have a hunch >>> this is just a nooby mistake, but I''m at a loss. Any help would be >>> greatly appreciated! >> >>> <% for member in @members %> >>> <li><%= link_to h(member.first_name) + " " + h(member.last_name), >>> edit_member_path(player) %></li> >>> <% end %> >> >> Your log file will tell you more - like the line number (it''s a stack >> trace). >> >> generally one of your variables is a nil. The line number should >> help. >> >> You could try logging the values out. Some people would use the built >> in debugger to help out. >> >> cheers, >> Jodi > > > > Thanks Jodi for the quick response! > > The log says its the first line: > > <% for player in @players %>If that''s the case, then it can only be @players Your controller action for this view must set this collection. Go look at the action and verify that @players is set to a legitimate value. Cheers, Jodi --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jamal Soueidan
2007-Sep-01 20:06 UTC
Re: You have a nil object when you didn''t expect it!
or check if its nil before using it, so it doesnt throw any exception again :) either this or that -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---