Class: Rearview::DashboardChildrenController

Inherits:
ApplicationController show all
Defined in:
app/controllers/rearview/dashboard_children_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/rearview/dashboard_children_controller.rb', line 12

def create
  @dashboard = Rearview::Dashboard.new
  @dashboard.name = params[:name]
  @dashboard.user = current_user
  @dashboard.description = params[:description]
  if params[:dashboard_id]
    @dashboard.parent=Rearview::Dashboard.find(params[:dashboard_id])
  end
  @dashboard.save!
  render 'rearview/dashboards/show'
end

#indexObject



4
5
6
7
8
9
10
11
# File 'app/controllers/rearview/dashboard_children_controller.rb', line 4

def index
  @dashboards = if params[:dashboard_id]
                  Rearview::Dashboard.find(params[:dashboard_id]).children
                else
                  []
                end
  render 'rearview/dashboards/index'
end