Hi I''m a newbie here and to RoR, so forgive me if this is an over simple question. I''m running through the PragProg Agile Web Development with Ruby on Rails, and I''ve got stuck on the Depot application. When trying to view the ''store'' I get this error: NoMethodError in Store#index.rhtml ****** Showing app/views/store/index.rhtml where line #3 raised: You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occured while evaluating nil.each Extracted source (around line #3): 1: <table cellpadding="5" cellspacing="0"> 2: <% 3: for product in @products 4: %> 5: <tr valign="top"> 6: ****** I''m Running: Ruby version 1.8.4 (i486-linux) [Ubuntu] RubyGems version 0.9.0 Rails version 1.1.4 Environment development Database adapter mysql I''ve retraced all the steps given in the book - but can''t resolve the problem - what are the likely causes of this to be? Is this most likely to be the call to the database? Thanks Angela --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Eric.Schwarzkopf-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org
2006-Sep-01 09:15 UTC
Re: NoMethodError [depot]
Hi Angela, if you didn''t mistype anything in product.rb and store_controller.rb, I''d say there''s a problem with the db. Look in depot/log/development.log for any errors and check the db whether the required tables exists and are populated. Best regards, Eric --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 9/1/06, ange <angela.hilton-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Hi > > I''m a newbie here and to RoR, so forgive me if this is an over simple > question. > > I''m running through the PragProg Agile Web Development with Ruby on > Rails, and I''ve got stuck on the Depot application. > > When trying to view the ''store'' I get this error: > NoMethodError in Store#index.rhtml > > ****** > Showing app/views/store/index.rhtml where line #3 raised: > > You have a nil object when you didn''t expect it! > You might have expected an instance of Array. > The error occured while evaluating nil.each > > Extracted source (around line #3): > > 1: <table cellpadding="5" cellspacing="0"> > 2: <% > 3: for product in @products > 4: %> > 5: <tr valign="top"> > 6: > ****** > > I''m Running: > Ruby version 1.8.4 (i486-linux) [Ubuntu] > RubyGems version 0.9.0 > Rails version 1.1.4 > Environment development > Database adapter mysql > > I''ve retraced all the steps given in the book - but can''t resolve the > problem - what are the likely causes of this to be? Is this most > likely to be the call to the database? > > Thanks > AngelaLine 3 calls for @products which is nil at the time in the index view, meaning that there are no products in your variable. Do you have something that populates the instance variable @products in your StoreController#index method? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
thanks both for this this problem was actually caused by: <%=@content_for_layout%> being missing from store.rhtm it''s all working just fine now - i just have much less hair! Thanks! A --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 9/1/06, ange <angela.hilton-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > thanks both for this > > this problem was actually caused by: > <%=@content_for_layout%> > > being missing from store.rhtm > > it''s all working just fine now - i just have much less hair! > > Thanks! > A > > > > > ange,Glad you found it. With some discussion about recently about depricated usages, with warnings and such available in plugins etc, the usage of @content_for_layour is depricated. Instead you should use <%= yield %> or <%= yeild :layout %> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---