Sha256: 3bcd55bb30993cf02ceaebcd6e5817d99f6395ae7d3fa462573449b14bf4f204

Contents?: true

Size: 1.1 KB

Versions: 15

Compression:

Stored size: 1.1 KB

Contents

class OrdersController < ApplicationController
  before_action :set_order, only: [:show, :edit, :update, :destroy]

  # GET /orders
  def index
    @orders = Order.all
  end

  # GET /orders/1
  def show
  end

  # GET /orders/new
  def new
    @order = Order.new
  end

  # GET /orders/1/edit
  def edit
  end

  # POST /orders
  def create
    @order = Order.new(order_params)

    if @order.save
      redirect_to @order, notice: 'Order was successfully created.'
    else
      render action: 'new'
    end
  end

  # PATCH/PUT /orders/1
  def update
    if @order.update(order_params)
      redirect_to @order, notice: 'Order was successfully updated.'
    else
      render action: 'edit'
    end
  end

  # DELETE /orders/1
  def destroy
    @order.destroy
    redirect_to orders_url, notice: 'Order was successfully destroyed.'
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_order
      @order = Order.find(params[:id])
    end

    # Only allow a trusted parameter "white list" through.
    def order_params
      params.require(:order).permit!
    end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
opay-1.3.2 spec/dummy/app/controllers/orders_controller.rb
opay-1.3.1 spec/dummy/app/controllers/orders_controller.rb
opay-1.3.0 spec/dummy/app/controllers/orders_controller.rb
opay-1.2.8 spec/dummy/app/controllers/orders_controller.rb
opay-1.2.7 spec/dummy/app/controllers/orders_controller.rb
opay-1.2.6 spec/dummy/app/controllers/orders_controller.rb
opay-1.2.5 spec/dummy/app/controllers/orders_controller.rb
opay-1.2.4 spec/dummy/app/controllers/orders_controller.rb
opay-1.2.3 spec/dummy/app/controllers/orders_controller.rb
opay-1.2.2 spec/dummy/app/controllers/orders_controller.rb
opay-1.2.1 spec/dummy/app/controllers/orders_controller.rb
opay-1.2.0 spec/dummy/app/controllers/orders_controller.rb
opay-1.1.6 spec/dummy/app/controllers/orders_controller.rb
opay-1.1.5 spec/dummy/app/controllers/orders_controller.rb
opay-1.1.4 spec/dummy/app/controllers/orders_controller.rb