Sha256: 572f45c88aeaee1b77c4cb6939cb50809896420bfd22a68319712ed49e87cdf8

Contents?: true

Size: 1 KB

Versions: 3

Compression:

Stored size: 1 KB

Contents

#---
# Excerpted from "Agile Web Development with Rails, 2nd Ed."
# We make no guarantees that this code is fit for any purpose. 
# Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book information.
#---
# Schema as of June 12, 2006 15:45 (schema version 7)
#
# Table name: orders
#
#  id       :integer(11)   not null, primary key
#  name     :string(255)   
#  address  :text          
#  email    :string(255)   
#  pay_type :string(10)    
#




class Order < ActiveRecord::Base


  
  has_many :line_items


  
  PAYMENT_TYPES = [
    #  Displayed        stored in db
    [ "Check",          "check" ],
    [ "Credit card",    "cc"   ],
    [ "Purchase order", "po" ]
  ]
  
  # ...
  

  
  validates_presence_of :name, :address, :email, :pay_type
  validates_inclusion_of :pay_type, :in => PAYMENT_TYPES.map {|disp, value| value}
  
  # ...
  

  
  def add_line_items_from_cart(cart)
    cart.items.each do |item|
      li = LineItem.from_cart_item(item)
      line_items << li 
    end 
  end 
  



end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
amrita2-2.0.0 sample/depot/app/models/order.rb
amrita2-2.0.1 sample/depot/app/models/order.rb
amrita2-2.0.2 sample/depot/app/models/order.rb