Class: Products

Inherits:
Items
  • Object
show all
Defined in:
app/controllers/products.rb

Instance Method Summary collapse

Instance Method Details

#buyObject



2
3
4
# File 'app/controllers/products.rb', line 2

def buy    
  @order = Models::Order.new
end

#checkoutObject



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/products.rb', line 6

def checkout
  @order = Models::Order.new params.order
  
  respond_to do |f|
    if @order.valid?
      flash.sticky_info = t :order_created, name: @model.name, price: @model.price_with_currency
      OrderMailer.submit(@order, @model).deliver
      f.js
    else
      f.js{render action: :buy}        
    end
  end
end