I have the an error such as undefined method ''each'' pls can any one find the error from the code given below <center><%=@b%></center> <center><h2>WELCOME IN YOUR PROFILE</h2> <%@usercart=Usrecart.find_by_user_id(@b)%> <%if @usercart.blank?%> <br> <br> <br> <br> <h2>THERE IS NO PRODUCT</h2> <%end%> <%if !@usercart.blank?%> <% for u in @usercart %> <% for column in u.content_columns %> <%=h u.send(column.name) %> <%end%> <%end%> <%=@usercart.user_id%> <%end%> <%=link_to "ADD NEW ITEM",:action=>''index'',:id=>@usercart.user_id%> </center> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
subimage interactive
2008-Mar-12 05:26 UTC
Re: undefined method `each'' for #<Usrecart:0x46d1678>
<%@usercart=Usrecart.find_by_user_id(@b)%> Typo much? Shouldn''t that be Usercart........ On Tue, Mar 11, 2008 at 10:19 PM, sharan <tsingh.sharan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I have the an error such as undefined method ''each'' > pls can any one find the error from the code given below > > <center><%=@b%></center> > <center><h2>WELCOME IN YOUR PROFILE</h2> > <%@usercart=Usrecart.find_by_user_id(@b)%> > <%if @usercart.blank?%> > <br> > <br> > <br> > <br> > <h2>THERE IS NO PRODUCT</h2> > <%end%> > <%if !@usercart.blank?%> > <% for u in @usercart %> > <% for column in u.content_columns %> > <%=h u.send(column.name) %> > <%end%> > <%end%> > <%=@usercart.user_id%> > <%end%> > <%=link_to "ADD NEW ITEM",:action=>''index'',:id=>@usercart.user_id%> > </center> > > >-- -------------------- seth at subimage interactive ----- http://sublog.subimage.com ----- Cashboard - Estimates, invoices, and time tracking software - for free! http://www.getcashboard.com ----- Substruct - Open source RoR e-commerce software. http://code.google.com/p/substruct/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Mar-12 07:41 UTC
Re: undefined method `each'' for #<Usrecart:0x46d1678>
On 12 Mar 2008, at 05:19, sharan wrote:> > I have the an error such as undefined method ''each'' > pls can any one find the error from the code given below >It looks like you''re half expecting @usercart to be an array since you''re trying to iterate over it, but it isn''t. Fred> <center><%=@b%></center> > <center><h2>WELCOME IN YOUR PROFILE</h2> > <%@usercart=Usrecart.find_by_user_id(@b)%> > <%if @usercart.blank?%> > <br> > <br> > <br> > <br> > <h2>THERE IS NO PRODUCT</h2> > <%end%> > <%if !@usercart.blank?%> > <% for u in @usercart %> > <% for column in u.content_columns %> > <%=h u.send(column.name) %> > <%end%> > <%end%> > <%=@usercart.user_id%> > <%end%> > <%=link_to "ADD NEW ITEM",:action=>''index'',:id=>@usercart.user_id%> > </center> > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
@usercart=Usrecart.find_all_by_user_id(@b) note the _all_ in the find method On 12 Mrz., 08:41, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 12 Mar 2008, at 05:19, sharan wrote: > > > > > I have the an error such as undefined method ''each'' > > pls can any one find the error from the code given below > > It looks like you''re half expecting @usercart to be an array since > you''re trying to iterate over it, but it isn''t. > > Fred > > > <center><%=@b%></center> > > <center><h2>WELCOME IN YOUR PROFILE</h2> > > <%@usercart=Usrecart.find_by_user_id(@b)%> > > <%if @usercart.blank?%> > > <br> > > <br> > > <br> > > <br> > > <h2>THERE IS NO PRODUCT</h2> > > <%end%> > > <%if !...@usercart.blank?%> > > <% for u in @usercart %> > > <% for column in u.content_columns %> > > <%=h u.send(column.name) %> > > <%end%> > > <%end%> > > <%...@usercart.user_id%> > > <%end%> > > <%=link_to "ADD NEW ITEM",:action=>''index'',:id=>@usercart.user_id%> > > </center>--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---