Class Product
In: app/models/product.rb
Parent: ActiveRecord::Base

A Product is something we can sell (but only if we’re passed its date_available attribute).

Methods

Public Class methods

Return a list of products we can sell (which means they have to be available). Show the most recently available first.

[Source]

    # File app/models/product.rb, line 16
16:   def self.salable_items
17:     find(:all,
18:          :conditions => "date_available <= now()", 
19:          :order      => "date_available desc")
20:   end

Protected Instance methods

Validate that the product price is a positive Float.

[Source]

    # File app/models/product.rb, line 25
25:   def validate  #:doc:
26:     errors.add(:price, "should be positive") unless price > 0.0
27:   end

[Validate]