Sha256: cbac9ff09ca415e1b534b2e3bac6be3520b699e76fb8645134aca222dd0a25f7

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

class BicyclesController < ApplicationController
  before_action :set_bicycle, only: [:show, :edit, :update, :destroy]

  # GET /bicycles
  def index
    @bicycles = Bicycle.all
  end

  # GET /bicycles/1
  def show
  end

  # GET /bicycles/new
  def new
    @bicycle = Bicycle.new
  end

  # GET /bicycles/1/edit
  def edit
  end

  # POST /bicycles
  def create
    @bicycle = Bicycle.new(bicycle_params)

    if @bicycle.save
      redirect_to @bicycle, notice: 'Bicycle was successfully created.'
    else
      render :new
    end
  end

  # PATCH/PUT /bicycles/1
  def update
    if @bicycle.update(bicycle_params)
      redirect_to @bicycle, notice: 'Bicycle was successfully updated.'
    else
      render :edit
    end
  end

  # DELETE /bicycles/1
  def destroy
    @bicycle.destroy
    redirect_to bicycles_url, notice: 'Bicycle was successfully destroyed.'
  end

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

    # Only allow a trusted parameter "white list" through.
    def bicycle_params
      params.require(:bicycle).permit(:name, :price, :qty)
    end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
simple_cart-0.0.5 spec/dummy/app/controllers/bicycles_controller.rb
simple_cart-0.0.4 spec/dummy/app/controllers/bicycles_controller.rb
simple_cart-0.0.3 test/dummy/app/controllers/bicycles_controller.rb
simple_cart-0.0.2 test/dummy/app/controllers/bicycles_controller.rb