SHARE
TWEET

Untitled

a guest Aug 2nd, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class PartOrdersController < ApplicationController
  2.   def create
  3.     @part_order = PartOrder.new(part_order_params)
  4.     @part_order.cart = Cart.find(session[:cart_id])
  5.     @part_order.add_line_items_from_cart(@cart)
  6.  
  7.     if @part_order.save
  8.       Cart.destroy(session[:cart_id])
  9.       session[:cart_id] = nil
  10.       redirect_to :root, notice: 'Спасибо за заявку! Наши менеджеры скоро свяжутся с вами.'
  11.     else
  12.       render action: 'new'
  13.     end
  14.   end
  15.  
  16.   private
  17.  
  18.   def part_order_params
  19.     params.require(:part_order).permit(
  20.       :name,
  21.       :email,
  22.       :phone,
  23.       :comment,
  24.       :payment_method,
  25.       :delivery_method
  26.     )
  27.   end
  28. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top