Sha256: da68dcd43e423d739c77888eb9fc3cf23a2408b4e0bde153fcfa12c3b16b63a8

Contents?: true

Size: 1.12 KB

Versions: 7

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

# Controller for Tools, like "Skillet"
class ToolsController < ApplicationController
  before_action :set_tool, only: %i[show edit update destroy]

  # GET /tools
  def index
    @tools = Tool.all
  end

  # GET /tools/1
  def show; end

  # GET /tools/new
  def new
    @tool = Tool.new
  end

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

  # POST /tools
  def create
    @tool = Tool.new(tool_params)

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

  # PATCH/PUT /tools/1
  def update
    if @tool.update(tool_params)
      redirect_to @tool, notice: 'Tool was successfully updated.'
    else
      render :edit
    end
  end

  # DELETE /tools/1
  def destroy
    @tool.destroy
    redirect_to tools_url, notice: 'Tool was successfully destroyed.'
  end

  private

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

  # Only allow a list of trusted parameters through.
  def tool_params
    params.require(:tool).permit(:name, :description, :composition)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cookbook-0.1.6 spec/dummy/app/controllers/tools_controller.rb
cookbook-0.1.5 spec/dummy/app/controllers/tools_controller.rb
cookbook-0.1.4 spec/dummy/app/controllers/tools_controller.rb
cookbook-0.1.3 spec/dummy/app/controllers/tools_controller.rb
cookbook-0.1.2 spec/dummy/app/controllers/tools_controller.rb
cookbook-0.1.1 spec/dummy/app/controllers/tools_controller.rb
cookbook-0.1.0 spec/dummy/app/controllers/tools_controller.rb