Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Shared::OrdersController < ApplicationController
- layout 'admin/panel'
- before_action :set_order , only: [:edit , :update, :show, :destroy]
- def index
- @orders = Order.all
- end
- def new
- @order = Order.new
- end
- def create
- @order = Order.new(params_order)
- if @order.save
- redirect_to shared_orders_path, notice: "Pedido Salvo com sucesso!!"
- else
- render :new
- end
- end
- def edit
- end
- def update
- if @order.update(params_order)
- redirect_to shared_orders_path, notice: "Pedido Editado com sucesso!!"
- else
- render :edit
- end
- end
- def show
- end
- def destroy
- if @order.destroy
- redirect_to shared_orders_path, notice: "Pedido excluido com sucesso!!"
- else
- render :index, notice: "Erro ao Excluir Pedido"
- end
- end
- private
- def set_order
- @order = Order.find(params[:id])
- end
- def params_order
- params.require(:order).permit(
- :numero_orcamento,
- :numero_pedido,
- :nome_cliente,
- :codigo_rastreio,
- :link_pedido,
- :status,
- :data_aprovacao,
- :modo_envio,
- :total)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement