Sha256: f3295ce7ec032736b7e09e80362186aa691ddadd1748a71e8b3a18c69422668f

Contents?: true

Size: 1.78 KB

Versions: 2

Compression:

Stored size: 1.78 KB

Contents

class FoosController < ApplicationController
  # GET /foos
  # GET /foos.xml
  def index
    @foos = Foo.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @foos }
    end
  end

  # GET /foos/1
  # GET /foos/1.xml
  def show
    @foo = Foo.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @foo }
    end
  end

  # GET /foos/new
  # GET /foos/new.xml
  def new
    @foo = Foo.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @foo }
    end
  end

  # GET /foos/1/edit
  def edit
    @foo = Foo.find(params[:id])
  end

  # POST /foos
  # POST /foos.xml
  def create
    @foo = Foo.new(params[:foo])

    respond_to do |format|
      if @foo.save
        format.html { redirect_to(@foo, :notice => 'Foo was successfully created.') }
        format.xml  { render :xml => @foo, :status => :created, :location => @foo }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @foo.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /foos/1
  # PUT /foos/1.xml
  def update
    @foo = Foo.find(params[:id])

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

  # DELETE /foos/1
  # DELETE /foos/1.xml
  def destroy
    @foo = Foo.find(params[:id])
    @foo.destroy

    respond_to do |format|
      format.html { redirect_to(foos_url) }
      format.xml  { head :ok }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mir_extensions-1.1.0 app/controllers/foos_controller.rb
mir_extensions-1.0.0 app/controllers/foos_controller.rb