I get this Error message in my browser SyntaxError in ProductsController#index /Users/musdev/work/depot/app/models/product.rb:11: Invalid char `\x1B'' in expression The code in my product.rb file class Product < ActiveRecord::Base validates_presence_of :title, :description, :image_url validates_numericality_of :price validate :price_must_be_at_least_a_cent validates_uniqueness_of :title validates_format_of :image_url, :with => %r{\.(gif|jpg|png)$}i, :message => ''must be URL for GIF, JPG'' + ''or PNG image.'' end def self.find_products_for_sale find(:all, :order => "title") end def price_must_be_at_least_a_cent errors.add(:price, ''should be at least 0.01'') if price.nil? || price < 0.01 end what does this mean? I dont see anything on that line Regards -- 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.
Check out ProductsController # index also please On Wed, Aug 4, 2010 at 12:30 PM, Musdev Musdev <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I get this Error message in my browser > SyntaxError in ProductsController#index > > /Users/musdev/work/depot/app/models/product.rb:11: Invalid char `\x1B'' > in expression > > > The code in my product.rb file > > class Product < ActiveRecord::Base > validates_presence_of :title, :description, :image_url > validates_numericality_of :price > validate :price_must_be_at_least_a_cent > validates_uniqueness_of :title > validates_format_of :image_url, > :with => %r{\.(gif|jpg|png)$}i, > :message => ''must be URL for GIF, JPG'' + > ''or PNG image.'' > end > def self.find_products_for_sale > find(:all, :order => "title") > end > > > def price_must_be_at_least_a_cent > errors.add(:price, ''should be at least 0.01'') if price.nil? || > price < 0.01 > end > > what does this mean? I dont see anything on that line > > Regards > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- Thanks: Rajeev sharma -- 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.
On Wed, Aug 4, 2010 at 03:00, Musdev Musdev <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I get this Error message in my browser > SyntaxError in ProductsController#index > > /Users/musdev/work/depot/app/models/product.rb:11: Invalid char `\x1B'' > in expression > > > The code in my product.rb fileWhich of those lines is #11? I don''t see immediately any obvious bad chars in what you posted, but perhaps that''s due in part to the email processing. Have you tried deleting and retyping that line? -Dave -- Specialization is for insects. -RAH | Have Pun, Will Babble! -me Programming Blog: http://codosaur.us | Work: http://davearonson.com Leadership Blog: http://dare2xl.com | Play: http://davearonson.net * * * * * WATCH THIS SPACE * * * * * | Ruby: http://mars.groupsite.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.
Dave Aronson wrote:> On Wed, Aug 4, 2010 at 03:00, Musdev Musdev <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > wrote: > >> I get this Error message in my browser >> �SyntaxError in ProductsController#index >> >> /Users/musdev/work/depot/app/models/product.rb:11: Invalid char `\x1B'' >> in expression >> >> >> The code in my product.rb file > > Which of those lines is #11? I don''t see immediately any obvious bad > chars in what you posted, but perhaps that''s due in part to the email > processing. Have you tried deleting and retyping that line? > > -Dave > > -- > Specialization is for insects. -RAH �| Have Pun, Will Babble! -me > Programming Blog: http://codosaur.us | Work: http://davearonson.com > Leadership Blog: �http://dare2xl.com | Play: http://davearonson.net > * * * * * WATCH THIS SPACE * * * * * | Ruby: http://mars.groupsite.comI tried deleting and retyping the line without touching anything else and now I see this error message in my browser NoMethodError in Products#index Showing app/views/products/index.html.erb where line #6 raised: You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occurred while evaluating nil.each Extracted source (around line #6): 3: 4: <table> 5: 6: <% @products.each do |product| %> 7: <tr class="<%= cycle(''list-line-odd'', ''list-line-even'') %>"> 8: <td> 9: <%= image_tag product.image_url, :class => ''list-image'' %> -- 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.
Musdev Musdev wrote:> Showing app/views/products/index.html.erb where line #6 raised: > > You have a nil object when you didn''t expect it! > You might have expected an instance of Array. > The error occurred while evaluating nil.each > > Extracted source (around line #6): > > 3: > 4: <table> > 5: > 6: <% @products.each do |product| %>Seems pretty obvious... @products is nil. That issue is in your controller. -- 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.
Ar Chron wrote:> Musdev Musdev wrote: >> Showing app/views/products/index.html.erb where line #6 raised: >> >> You have a nil object when you didn''t expect it! >> You might have expected an instance of Array. >> The error occurred while evaluating nil.each >> >> Extracted source (around line #6): >> >> 3: >> 4: <table> >> 5: >> 6: <% @products.each do |product| %> > > Seems pretty obvious... @products is nil. That issue is in your > controller.lol thanks, I was about to take the sucker way out and start over, but how will I ever learn. I just created a new Product.new object in my controller and stored it in @products. Thanks -- 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.