Sha256: c9a1671f64de187f12c442ee4fe98ff21c2c19882ca1aef46de46d03e415fad1

Contents?: true

Size: 1.68 KB

Versions: 2

Compression:

Stored size: 1.68 KB

Contents

module LesliGuard
  class Dashboard::ComponentsController < ApplicationController
    before_action :set_dashboard_component, only: %i[ show edit update destroy ]

    # GET /dashboard/components
    def index
      @dashboard_components = Dashboard::Component.all
    end

    # GET /dashboard/components/1
    def show
    end

    # GET /dashboard/components/new
    def new
      @dashboard_component = Dashboard::Component.new
    end

    # GET /dashboard/components/1/edit
    def edit
    end

    # POST /dashboard/components
    def create
      @dashboard_component = Dashboard::Component.new(dashboard_component_params)

      if @dashboard_component.save
        redirect_to @dashboard_component, notice: "Component was successfully created."
      else
        render :new, status: :unprocessable_entity
      end
    end

    # PATCH/PUT /dashboard/components/1
    def update
      if @dashboard_component.update(dashboard_component_params)
        redirect_to @dashboard_component, notice: "Component was successfully updated.", status: :see_other
      else
        render :edit, status: :unprocessable_entity
      end
    end

    # DELETE /dashboard/components/1
    def destroy
      @dashboard_component.destroy
      redirect_to dashboard_components_url, notice: "Component was successfully destroyed.", status: :see_other
    end

    private
      # Use callbacks to share common setup or constraints between actions.
      def set_dashboard_component
        @dashboard_component = Dashboard::Component.find(params[:id])
      end

      # Only allow a list of trusted parameters through.
      def dashboard_component_params
        params.fetch(:dashboard_component, {})
      end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lesli_guard-0.3.0 app/controllers/lesli_guard/dashboard/components_controller.rb
lesli_guard-0.2.0 app/controllers/lesli_guard/dashboard/components_controller.rb