Sha256: b6f087dbbe2a9cb2972a6ce7e8c2b1112321c8da4db9028c912d0323eb588dd6

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

class OrderLinesController < ApplicationController
  before_action :set_order_line, only: [:show, :edit, :update, :destroy]

  # GET /order_lines
  def index
    @order_lines = OrderLine.all
  end

  # GET /order_lines/1
  def show
  end

  # GET /order_lines/new
  def new
    @order_line = OrderLine.new
  end

  # GET /order_lines/1/edit
  def edit
  end

  # POST /order_lines
  def create
    @order_line = OrderLine.new(order_line_params)

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

  # PATCH/PUT /order_lines/1
  def update
    if @order_line.update(order_line_params)
      redirect_to @order_line, notice: 'Order line was successfully updated.'
    else
      render action: 'edit'
    end
  end

  # DELETE /order_lines/1
  def destroy
    @order_line.destroy
    redirect_to order_lines_url, notice: 'Order line was successfully destroyed.'
  end

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

    # Only allow a trusted parameter "white list" through.
    def order_line_params
      params.require(:order_line).permit(:order_header_id, :price, :quantity, :item_name)
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ext_form-0.1.5 spec/dummy/app/controllers/order_lines_controller.rb
ext_form-0.1.4 spec/dummy/app/controllers/order_lines_controller.rb