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
On Wed, Aug 4, 2010 at 12:30 PM, Musdev M. [email protected]
wrote:

validates_presence_of :title, :description, :image_url
end

http://groups.google.com/group/rubyonrails-talk?hl=en.


Thanks:
Rajeev sharma

On Wed, Aug 4, 2010 at 03:00, Musdev M. [email protected]
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

Dave A. wrote:

On Wed, Aug 4, 2010 at 03:00, Musdev M. [email protected]
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

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:


5:
6: <% @products.each do |product| %>
7:
8:

9: <%= image_tag product.image_url, :class => ‘list-image’ %>

Ar Chron wrote:

Musdev M. 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:


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

Musdev M. 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:


5:
6: <% @products.each do |product| %>

Seems pretty obvious… @products is nil. That issue is in your
controller.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs