Class: Prosperity::DashboardsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/prosperity/dashboards_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/prosperity/dashboards_controller.rb', line 21

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

#destroyObject



33
34
35
36
# File 'app/controllers/prosperity/dashboards_controller.rb', line 33

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

#editObject



17
18
19
# File 'app/controllers/prosperity/dashboards_controller.rb', line 17

def edit
  dashboard
end

#indexObject



5
6
7
# File 'app/controllers/prosperity/dashboards_controller.rb', line 5

def index
  @dashboards = Dashboard.all
end

#newObject



9
10
11
# File 'app/controllers/prosperity/dashboards_controller.rb', line 9

def new
  @dashboard = Dashboard.new
end

#showObject



13
14
15
# File 'app/controllers/prosperity/dashboards_controller.rb', line 13

def show
  dashboard
end