Sha256: c346df72b6ccf3998aece5a32df3954ff30b9e4b8f613536fedf91ca734a9d3c

Contents?: true

Size: 1.79 KB

Versions: 1

Compression:

Stored size: 1.79 KB

Contents

class ChipsController < ApplicationController
  # GET /chips
  # GET /chips.json
  def index
    @chips = Chip.all

    respond_to do |format|
      format.html # index.html.erb
      format.json { render json: @chips }
    end
  end

  # GET /chips/1
  # GET /chips/1.json
  def show
    @chip = Chip.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @chip }
    end
  end

  # GET /chips/new
  # GET /chips/new.json
  def new
    @chip = Chip.new

    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @chip }
    end
  end

  # GET /chips/1/edit
  def edit
    @chip = Chip.find(params[:id])
  end

  # POST /chips
  # POST /chips.json
  def create
    @chip = Chip.new(params[:chip])

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

  # PUT /chips/1
  # PUT /chips/1.json
  def update
    @chip = Chip.find(params[:id])

    respond_to do |format|
      if @chip.update_attributes(params[:chip])
        format.html { redirect_to @chip, notice: 'Chip was successfully updated.' }
        format.json { head :ok }
      else
        format.html { render action: "edit" }
        format.json { render json: @chip.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /chips/1
  # DELETE /chips/1.json
  def destroy
    @chip = Chip.find(params[:id])
    @chip.destroy

    respond_to do |format|
      format.html { redirect_to chips_url }
      format.json { head :ok }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
routespec-0.0.1 test/rails311/app/controllers/chips_controller.rb