Hi All, I''m working on a tutorial and am already stumped on the very first question... I can''t seem to figure it out. Here are the details: Objective Find Zombie where id = 1 and store it in a variable Resources zombies id name graveyard 1 Ash Glen Haven Memorial Cemetary 2 Bob Chapel Hill Cemetary 3 Jim My Fathers Basement Here''s what I''ve tried: t = Zombie.find(1) x = t.name and here''s the error I keep getting (or some similar variation): Sorry, Try Again #<NoMethodError: undefined method `id'' for "Ash":String> I''ve tried a ton of different variations, but am obviously approaching the problem incorrectly. Can anyone help me out? Thanks! Ryan -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Try the "rails console" command on your shell then type "x = Zombie.find(1).name" On Wed, May 18, 2011 at 11:22 PM, Ryan C. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi All, > > I''m working on a tutorial and am already stumped on the very first > question... I can''t seem to figure it out. Here are the details: > > > Objective > Find Zombie where id = 1 and store it in a variable > > Resources > zombies > id name graveyard > 1 Ash Glen Haven Memorial Cemetary > 2 Bob Chapel Hill Cemetary > 3 Jim My Fathers Basement > > > Here''s what I''ve tried: > > t = Zombie.find(1) > x = t.name > > and here''s the error I keep getting (or some similar variation): > > Sorry, Try Again > #<NoMethodError: undefined method `id'' for "Ash":String> > > > I''ve tried a ton of different variations, but am obviously approaching > the problem incorrectly. Can anyone help me out? > > Thanks! > Ryan > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks for the reply, Unfortunately, the tutorial provides the console and it''s expecting only a working answer. x = Zombie.find(1).name returns the same error I''m afraid. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Never mind, I''m an idiot. I assumed the objective was to get the zombie''s name. All it was asking for was the entry in the db. The first line was sufficient.. Thanks for the help. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.