Sha256: 7a0250430c57473f597527bdd175ec949be592ce6cb934e248181c8e740645be

Contents?: true

Size: 1.66 KB

Versions: 16

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.require(:entity).permit!.merge(state: "parked"))

    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

16 entries across 2 versions & 1 rubygems

Version Path
chillout-0.8.9 test/support/rails_5_1_1/app/controllers/entities_controller.rb
chillout-0.8.9 test/support/rails_4_0_0/app/controllers/entities_controller.rb
chillout-0.8.9 test/support/rails_4_0_13/app/controllers/entities_controller.rb
chillout-0.8.9 test/support/rails_4_1_0/app/controllers/entities_controller.rb
chillout-0.8.9 test/support/rails_4_1_16/app/controllers/entities_controller.rb
chillout-0.8.9 test/support/rails_4_2_0/app/controllers/entities_controller.rb
chillout-0.8.9 test/support/rails_4_2_8/app/controllers/entities_controller.rb
chillout-0.8.9 test/support/rails_5_0_3/app/controllers/entities_controller.rb
chillout-0.8.8 test/support/rails_4_0_0/app/controllers/entities_controller.rb
chillout-0.8.8 test/support/rails_4_0_13/app/controllers/entities_controller.rb
chillout-0.8.8 test/support/rails_4_1_0/app/controllers/entities_controller.rb
chillout-0.8.8 test/support/rails_4_1_16/app/controllers/entities_controller.rb
chillout-0.8.8 test/support/rails_4_2_0/app/controllers/entities_controller.rb
chillout-0.8.8 test/support/rails_4_2_8/app/controllers/entities_controller.rb
chillout-0.8.8 test/support/rails_5_0_3/app/controllers/entities_controller.rb
chillout-0.8.8 test/support/rails_5_1_1/app/controllers/entities_controller.rb