Getting Error in browser

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.'   eend 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

Check out ProductsController # index also please

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

Dave Aronson 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.com

I 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' %>

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.

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