Sha256: c42aeb923565992cefeeb60785b895b6e192a747eb60a24103136b067ee73264

Contents?: true

Size: 1.81 KB

Versions: 32

Compression:

Stored size: 1.81 KB

Contents

class PlanetsController < ApplicationController
  before_action :set_planet, only: [:show, :edit, :update, :destroy]

  # GET /planets
  # GET /planets.json
  def index
    @planets = Planet.all
  end

  # GET /planets/1
  # GET /planets/1.json
  def show
  end

  # GET /planets/new
  def new
    @planet = Planet.new
  end

  # GET /planets/1/edit
  def edit
  end

  # POST /planets
  # POST /planets.json
  def create
    @planet = Planet.new(planet_params)

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

  # PATCH/PUT /planets/1
  # PATCH/PUT /planets/1.json
  def update
    respond_to do |format|
      if @planet.update(planet_params)
        format.html { redirect_to @planet, notice: 'Planet was successfully updated.' }
        format.json { render :show, status: :ok, location: @planet }
      else
        format.html { render :edit }
        format.json { render json: @planet.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /planets/1
  # DELETE /planets/1.json
  def destroy
    @planet.destroy
    respond_to do |format|
      format.html { redirect_to planets_url, notice: 'Planet was successfully destroyed.' }
      format.json { head :no_content }
    end
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_planet
      @planet = Planet.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.
    def planet_params
      params.require(:planet).permit(:name)
    end
end

Version data entries

32 entries across 4 versions & 1 rubygems

Version Path
tabulous-2.1.4 spec/applications/simple_tabs/rails_5-0-0/app/controllers/planets_controller.rb
tabulous-2.1.4 spec/applications/simple_tabs/rails_4-2-0/app/controllers/planets_controller.rb
tabulous-2.1.4 spec/applications/simple_tabs/rails_4-1-1/app/controllers/planets_controller.rb
tabulous-2.1.4 spec/applications/main/rails_5-0-0/app/controllers/planets_controller.rb
tabulous-2.1.4 spec/applications/bootstrap/rails_4-1-1/app/controllers/planets_controller.rb
tabulous-2.1.4 spec/applications/main/rails_4-2-0/app/controllers/planets_controller.rb
tabulous-2.1.4 spec/applications/main/rails_4-1-1/app/controllers/planets_controller.rb
tabulous-2.1.4 spec/applications/custom_renderer/rails_5-0-0/app/controllers/planets_controller.rb
tabulous-2.1.4 spec/applications/custom_renderer/rails_4-2-0/app/controllers/planets_controller.rb
tabulous-2.1.4 spec/applications/custom_renderer/rails_4-1-1/app/controllers/planets_controller.rb
tabulous-2.1.4 spec/applications/bootstrap/rails_5-0-0/app/controllers/planets_controller.rb
tabulous-2.1.4 spec/applications/bootstrap/rails_4-2-0/app/controllers/planets_controller.rb
tabulous-2.1.3 spec/applications/main/rails_4-1-1/app/controllers/planets_controller.rb
tabulous-2.1.3 spec/applications/bootstrap/rails_4-1-1/app/controllers/planets_controller.rb
tabulous-2.1.3 spec/applications/bootstrap/rails_4-2-0/app/controllers/planets_controller.rb
tabulous-2.1.3 spec/applications/custom_renderer/rails_4-1-1/app/controllers/planets_controller.rb
tabulous-2.1.3 spec/applications/custom_renderer/rails_4-2-0/app/controllers/planets_controller.rb
tabulous-2.1.3 spec/applications/main/rails_4-2-0/app/controllers/planets_controller.rb
tabulous-2.1.3 spec/applications/simple_tabs/rails_4-1-1/app/controllers/planets_controller.rb
tabulous-2.1.3 spec/applications/simple_tabs/rails_4-2-0/app/controllers/planets_controller.rb