Sha256: 936fb766cafc48cec4acadbdc6c2a692038a342ac7b854de6462da4af1e65c42

Contents?: true

Size: 1.16 KB

Versions: 14

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

# :nocov:
# Super basic controller for Things
class ThingsController < ApplicationController
  before_action :set_thing, only: %i[show edit update destroy]

  # GET /things
  def index
    @things = Thing.all
  end

  # GET /things/1
  def show; end

  # GET /things/new
  def new
    @thing = Thing.new
  end

  # GET /things/1/edit
  def edit; end

  # POST /things
  def create
    @thing = Thing.new(thing_params)

    if @thing.save
      redirect_to @thing, notice: 'Thing was successfully created.'
    else
      render :new
    end
  end

  # PATCH/PUT /things/1
  def update
    if @thing.update(thing_params)
      redirect_to @thing, notice: 'Thing was successfully updated.'
    else
      render :edit
    end
  end

  # DELETE /things/1
  def destroy
    @thing.destroy
    redirect_to things_url, notice: 'Thing was successfully destroyed.'
  end

  private

  # Use callbacks to share common setup or constraints between actions.
  def set_thing
    @thing = Thing.find(params[:id])
  end

  # Only allow a list of trusted parameters through.
  def thing_params
    params.require(:thing).permit(:name, :description)
  end
end
# :nocov:

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
works_cited-0.1.14 spec/dummy/app/controllers/things_controller.rb
works_cited-0.1.13 spec/dummy/app/controllers/things_controller.rb
works_cited-0.1.11 spec/dummy/app/controllers/things_controller.rb
works_cited-0.1.10 spec/dummy/app/controllers/things_controller.rb
works_cited-0.1.9 spec/dummy/app/controllers/things_controller.rb
works_cited-0.1.8 spec/dummy/app/controllers/things_controller.rb
works_cited-0.1.7 spec/dummy/app/controllers/things_controller.rb
works_cited-0.1.6 spec/dummy/app/controllers/things_controller.rb
works_cited-0.1.5 spec/dummy/app/controllers/things_controller.rb
works_cited-0.1.4 spec/dummy/app/controllers/things_controller.rb
works_cited-0.1.3 spec/dummy/app/controllers/things_controller.rb
works_cited-0.1.2 spec/dummy/app/controllers/things_controller.rb
works_cited-0.1.1 spec/dummy/app/controllers/things_controller.rb
works_cited-0.1.0 spec/dummy/app/controllers/things_controller.rb