Hi--

I'm having trouble with a syntax error, which I'm working with on page
89 of Agile Web Development. I'm getting the following syntax error:

/Users/pdenlinger/Sites/depot/app/models/product.rb:4: syntax error,
unexpected tSYMBEG, expecting kDO or '{' or '('
  validates_numericality_of :price
                             ^
/Users/pdenlinger/Sites/depot/app/models/product.rb:9: syntax error,
unexpected tASSOC, expecting kEND
...                   :message => 'must be a URL for GIF, JPG' ...
                              ^

The original code I have on the model (product.rb) is:

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 a URL for GIF, JPG' + 'or
PNG image'

protected
  def price_must_be_at_least_a_cent
    errors.add(:price, 'should be at least 0.01') if price.nil? ||
    price < 0.01
  end

end


Thanks for your help.

Paul

--

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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.


Reply via email to