Code Search for Developers
 
 
  

product.rb from crlove at Krugle


Show product.rb syntax highlighted

class Product < ActiveRecord::Base
  has_many :line_items
  
  def self.find_products_for_sale
    find(:all, :order => "title")
  end
  
  validates_presence_of :title, :description, :image_url
  validates_numericality_of :price, :only_integer => true
  validates_uniqueness_of :title
  validates_format_of :image_url,
                      :with    => %r{\.(gif|jpg|png)$}i,
                      :message => "must be a URL for a GIF, JPG or PNG image"
  
  protected
  def validate
    errors.add(:price, "should be positive") if price.nil? || price <= 0
  end
end




See more files for this project here

crlove

Online psychological-test-based friend-making system.

Project homepage: http://sourceforge.net/projects/crlove
Programming language(s): Java,JavaScript,Ruby,XML
License: other

  cart.rb
  cart_item.rb
  line_item.rb
  order.rb
  product.rb
  user.rb