Class: Storytime::Dashboard::NavigationsController

Inherits:
Storytime::DashboardController show all
Defined in:
app/controllers/storytime/dashboard/navigations_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate_user!, #current_user, #setup, #user_signed_in?

Methods included from Concerns::CurrentSite

#current_storytime_site

Methods included from Concerns::ControllerContentFor

#content_for, #content_for?, #view_context

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/storytime/dashboard/navigations_controller.rb', line 18

def create
  authorize current_storytime_site, :manage?
  @navigation = Navigation.new(navigation_params)

  respond_to do |format|
    if @navigation.save
      format.html { redirect_to [storytime, :edit, :dashboard, @navigation], notice: t('dashboard.navigations.create.success') }
    else
      format.html { render :new }
    end
  end
end

#destroyObject



49
50
51
52
53
54
55
56
57
58
# File 'app/controllers/storytime/dashboard/navigations_controller.rb', line 49

def destroy
  authorize current_storytime_site, :manage?
  @navigation = Navigation.find(params[:id])
  @navigation.destroy
  flash[:notice] = I18n.t('flash.navigations.destroy.success') unless request.xhr?
  
  respond_with [:dashboard, @navigation] do |format|
    format.html{ redirect_to url_for([:dashboard, Storytime::Navigation]) }
  end
end

#editObject



31
32
33
34
# File 'app/controllers/storytime/dashboard/navigations_controller.rb', line 31

def edit
  authorize current_storytime_site, :manage?
  @navigation = Navigation.find(params[:id])
end

#indexObject



8
9
10
11
# File 'app/controllers/storytime/dashboard/navigations_controller.rb', line 8

def index
  authorize current_storytime_site, :manage?
  @navigations = Navigation.includes(:links)
end

#newObject



13
14
15
16
# File 'app/controllers/storytime/dashboard/navigations_controller.rb', line 13

def new
  authorize current_storytime_site, :manage?
  @navigation = Navigation.new
end

#updateObject



36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/controllers/storytime/dashboard/navigations_controller.rb', line 36

def update
  authorize current_storytime_site, :manage?
  @navigation = Navigation.find(params[:id])

  respond_to do |format|
    if @navigation.update(navigation_params)
      format.html { redirect_to [storytime, :edit, :dashboard, @navigation], notice: t('dashboard.navigations.update.success') }
    else
      format.html { render :edit }
    end
  end
end