Sha256: fe1dc1f998cb5499191ad790c2930c24534338c6297dff6e5bb1d8e2d1af23b8

Contents?: true

Size: 186 Bytes

Versions: 10

Compression:

Stored size: 186 Bytes

Contents

class Basket < ActiveRecord::Base
  has_and_belongs_to_many :items
  has_many :payments
  
  def price
    items.inject(0) do |total, item|
      total + item.price
    end
  end
  
end

Version data entries

10 entries across 5 versions & 2 rubygems

Version Path
restfulie-nosqlite-1.0.4 full-examples/rest_from_scratch/part_2/app/models/basket.rb
restfulie-nosqlite-1.0.4 full-examples/rest_from_scratch/part_3/app/models/basket.rb
restfulie-1.1.1 full-examples/rest_from_scratch/part_3/app/models/basket.rb
restfulie-1.1.1 full-examples/rest_from_scratch/part_2/app/models/basket.rb
restfulie-1.1.0 full-examples/rest_from_scratch/part_2/app/models/basket.rb
restfulie-1.1.0 full-examples/rest_from_scratch/part_3/app/models/basket.rb
restfulie-nosqlite-1.0.3 full-examples/rest_from_scratch/part_2/app/models/basket.rb
restfulie-nosqlite-1.0.3 full-examples/rest_from_scratch/part_3/app/models/basket.rb
restfulie-1.0.3 full-examples/rest_from_scratch/part_3/app/models/basket.rb
restfulie-1.0.3 full-examples/rest_from_scratch/part_2/app/models/basket.rb