Sha256: 6ae11fd61fd37987dd1d6a6bb728d421714d65f1cdd03f69c0cf1988b9113654

Contents?: true

Size: 1.66 KB

Versions: 3

Compression:

Stored size: 1.66 KB

Contents

class EntitiesController < ApplicationController
  def index
    @entities = Entity.all

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

  def show
    @entity = Entity.find(params[:id])

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

  def new
    @entity = Entity.new

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

  def edit
    @entity = Entity.find(params[:id])
  end

  def create
    @entity = Entity.new(params[:entity])

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

  def update
    @entity = Entity.find(params[:id])

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

  def destroy
    @entity = Entity.find(params[:id])
    @entity.destroy

    respond_to do |format|
      format.html { redirect_to entities_url }
      format.json { head :no_content }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
chillout-0.8.2 test/support/rails_3_2_13/app/controllers/entities_controller.rb
chillout-0.8.1 test/support/rails_3_2_13/app/controllers/entities_controller.rb
chillout-0.8.0 test/support/rails_3_2_13/app/controllers/entities_controller.rb