Sha256: 9a8e056c780729bac1af986da3031040d2bf69b3cb7a53dd911983ae8132b7a4

Contents?: true

Size: 1.97 KB

Versions: 27

Compression:

Stored size: 1.97 KB

Contents

class OrganismsController < ApplicationController
  
  skip_before_filter :find_organism
  before_action :set_organism, only: [:show, :edit, :update, :destroy]
  
  # GET /organisms
  # GET /organisms.json
  def index
    @organisms = Organism.all
  end

  # GET /organisms/1
  # GET /organisms/1.json
  def show
    session[:organism] = @organism.id
  end

  # GET /organisms/new
  # GET /organisms/new.json
  def new
    @organism = Organism.new
  end

  # GET /organisms/1/edit
  def edit
    
  end

  # POST /organisms
  # POST /organisms.json
  def create
    @organism = Organism.new(organism_params)

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

  # PUT /organisms/1
  # PUT /organisms/1.json
  def update
    respond_to do |format|
      if @organism.update_attributes(organism_params)
        format.html { redirect_to @organism, notice: 'Organism was successfully updated.' }
        format.json { head :no_content }
      else
        format.html { render action: "edit" }
        format.json { render json: @organism.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /organisms/1
  # DELETE /organisms/1.json
  def destroy
    
    @organism.destroy

    respond_to do |format|
      format.html { redirect_to organisms_url }
      format.json { head :no_content }
    end
  end
  
  private
  
    # Use callbacks to share common setup or constraints between actions.
    def set_organism
      @organism = Organism.find(params[:id])
    end
  
  # Never trust parameters from the scary internet, only allow the white list through.
    def organism_params
      params.require(:organism).permit(:title, :status)
    end
  
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
adherent-0.3.13 spec/dummy/app/controllers/organisms_controller.rb
adherent-0.3.12 spec/dummy/app/controllers/organisms_controller.rb
adherent-0.3.11 spec/dummy/app/controllers/organisms_controller.rb
adherent-0.3.10 spec/dummy/app/controllers/organisms_controller.rb
adherent-0.3.9 spec/dummy/app/controllers/organisms_controller.rb
adherent-0.3.7 spec/dummy/app/controllers/organisms_controller.rb
adherent-0.3.6 spec/dummy/app/controllers/organisms_controller.rb
adherent-0.3.5 spec/dummy/app/controllers/organisms_controller.rb
adherent-0.3.4 spec/dummy/app/controllers/organisms_controller.rb
adherent-0.3.3 spec/dummy/app/controllers/organisms_controller.rb
adherent-0.3.2 spec/dummy/app/controllers/organisms_controller.rb
adherent-0.3.1 spec/dummy/app/controllers/organisms_controller.rb
adherent-0.3.0 spec/dummy/app/controllers/organisms_controller.rb
adherent-0.2.9 spec/dummy/app/controllers/organisms_controller.rb
adherent-0.2.8 spec/dummy/app/controllers/organisms_controller.rb
adherent-0.2.7 spec/dummy/app/controllers/organisms_controller.rb
adherent-0.2.6 spec/dummy/app/controllers/organisms_controller.rb
adherent-0.2.5 spec/dummy/app/controllers/organisms_controller.rb
adherent-0.2.4 spec/dummy/app/controllers/organisms_controller.rb
adherent-0.2.3 spec/dummy/app/controllers/organisms_controller.rb