Class: Virgo::Admin::SlidesController

Inherits:
BaseController show all
Defined in:
app/controllers/virgo/admin/slides_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#authorize_admin_user, #search, #set_is_admin_view

Methods included from RenderHelper

#render_content, #with_format

Methods included from Virgo::ApplicationHelper

#action?, #admin?, #admin_access?, #admin_view?, #alerts, #base_errors, #category_timestamp, #column_timestamp, #compact_html, #controller?, #decode_html_entities, #expanded_post_url, #is_admin_view?, #page_url, #post_time_format, #post_timestamp, #production?, #redis_timestamp_key_for, #site, #site_key, #superuser?, #tabbed_param, #word_count

Instance Method Details

#createObject


10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/virgo/admin/slides_controller.rb', line 10

def create
  @slide = Slide.new(slide_params)

  if @slide.save
    flash[:notice] = "Your new slide has been added"
    redirect_to edit_admin_slideshow_path(@slide.slideshow)
  else
    render :new
  end
end

#destroyObject


46
47
48
49
50
51
# File 'app/controllers/virgo/admin/slides_controller.rb', line 46

def destroy
  authorize! :destroy, @slide
  @slide.destroy
  flash[:notice] = "Slide removed from slideshow"
  redirect_to edit_admin_slideshow_path(@slide.slideshow)
end

#editObject


21
22
# File 'app/controllers/virgo/admin/slides_controller.rb', line 21

def edit
end

#newObject


6
7
8
# File 'app/controllers/virgo/admin/slides_controller.rb', line 6

def new
  @slide = @slideshow.slides.new
end

#positionsObject


33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/virgo/admin/slides_controller.rb', line 33

def positions
  slide_data = params[:slides]

  slide_data.values.each do |data|
    slide = Slide.find(data[:id])
    authorize! :manage, slide
    slide.update!(position: data[:position])
  end


  head :ok
end

#updateObject


24
25
26
27
28
29
30
31
# File 'app/controllers/virgo/admin/slides_controller.rb', line 24

def update
  if @slide.update(slide_params)
    flash[:notice] = "Slide settings updated"
    redirect_to edit_admin_slideshow_path(@slide.slideshow)
  else
    render :edit
  end
end