Sha256: 2d4e2aac030c85f20ac7c305d5fd452ebdad4bb57c69c5e9c7af8463a7016172

Contents?: true

Size: 841 Bytes

Versions: 6

Compression:

Stored size: 841 Bytes

Contents

require_dependency "prosperity/application_controller"

module Prosperity
  class DashboardsController < ApplicationController
    def index
      @dashboards = Dashboard.all
    end

    def new
      @dashboard = Dashboard.new
    end

    def show
      dashboard
    end

    def edit
      dashboard
    end

    def create
      @dashboard = Dashboard.new
      @dashboard.title = params.fetch(:dashboard, {})[:title]
      @dashboard.default = false
      if @dashboard.save
        redirect_to edit_dashboard_path(@dashboard)
      else
        flash[:error] = @dashboard.errors.full_messages.to_sentence
        render action: :new
      end
    end

    def destroy
      dashboard.destroy
      redirect_to action: 'index'
    end

    private

    def dashboard
      @dashboard ||= Dashboard.find(params[:id])
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
prosperity-0.0.11 app/controllers/prosperity/dashboards_controller.rb
prosperity-0.0.10 app/controllers/prosperity/dashboards_controller.rb
prosperity-0.0.9 app/controllers/prosperity/dashboards_controller.rb
prosperity-0.0.8 app/controllers/prosperity/dashboards_controller.rb
prosperity-0.0.7 app/controllers/prosperity/dashboards_controller.rb
prosperity-0.0.6 app/controllers/prosperity/dashboards_controller.rb