# class CartsController

START:setup START:setup

### Public Instance Methods

create() click to toggle source

POST /carts POST /carts.json

    # File app/controllers/carts_controller.rb, line 33
    def create
      @cart = Cart.new(cart_params)

      respond_to do |format|
        if @cart.save
          format.html { redirect_to @cart, notice: 'Cart was successfully created.' }
          format.json { render action: 'show', status: :created, location: @cart }
        else
          format.html { render action: 'new' }
          format.json { render json: @cart.errors, status: :unprocessable_entity }
        end
      end
    end

destroy() click to toggle source

    DELETE /carts/1
    DELETE /carts/1.json

START:destroy

    # File app/controllers/carts_controller.rb, line 64
      def destroy
        @cart.destroy
        session[:cart_id] = nil
        respond_to do |format|
          format.html { redirect_to store_url }
          format.json { head :no_content }
        end
      end

edit() click to toggle source

GET /carts/1/edit

    # File app/controllers/carts_controller.rb, line 28
    def edit
    end

index() click to toggle source

    GET /carts

END:setup

    GET /carts.json

    # File app/controllers/carts_controller.rb, line 13
    def index
      @carts = Cart.all
    end

new() click to toggle source

GET /carts/new

    # File app/controllers/carts_controller.rb, line 23
    def new
      @cart = Cart.new
    end

show() click to toggle source

GET /carts/1 GET /carts/1.json

    # File app/controllers/carts_controller.rb, line 19
    def show
    end

update() click to toggle source

PATCH/PUT /carts/1 PATCH/PUT /carts/1.json

    # File app/controllers/carts_controller.rb, line 49
    def update
      respond_to do |format|
        if @cart.update(cart_params)
          format.html { redirect_to @cart, notice: 'Cart was successfully updated.' }
          format.json { head :no_content }
        else
          format.html { render action: 'edit' }
          format.json { render json: @cart.errors, status: :unprocessable_entity }
        end
      end
    end