Class: Admin::PageFilesController

Inherits:
AdminController show all
Defined in:
app/controllers/admin/page_files_controller.rb

Instance Attribute Summary

Attributes included from PagesCore::Authentication

#current_user

Instance Method Summary collapse

Methods inherited from PagesCore::AdminController

#redirect, underscore

Methods included from PagesCore::PoliciesHelper

#policy, #verify_policy, #verify_policy_with_proc

Methods included from PagesCore::ProcessTitler

inc_number_of_requests, original_title

Methods included from PagesCore::ErrorRenderer

#render_error

Methods included from PagesCore::Authentication

#authenticate!, #deauthenticate!, #logged_in?

Instance Method Details

#createObject


27
28
29
30
31
32
# File 'app/controllers/admin/page_files_controller.rb', line 27

def create
  @page_file = @page.files.new
  @page_file.update(page_file_params.merge(locale: @locale))
  flash[:notice] = "Error uploading file!" unless @page_file.valid?
  redirect_to_page
end

#destroyObject


45
46
47
48
49
# File 'app/controllers/admin/page_files_controller.rb', line 45

def destroy
  @page_file.destroy
  flash[:notice] = "File deleted"
  redirect_to_page
end

#editObject


34
# File 'app/controllers/admin/page_files_controller.rb', line 34

def edit; end

#indexObject


9
# File 'app/controllers/admin/page_files_controller.rb', line 9

def index; end

#newObject


25
# File 'app/controllers/admin/page_files_controller.rb', line 25

def new; end

#reorderObject


11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/admin/page_files_controller.rb', line 11

def reorder
  if params[:ids]
    files = Array(params[:ids]).map { |id| PageFile.find(id) }
    files.each_with_index { |f, i| f.update(position: i + 1) }
  end
  if request.xhr?
    head :ok
  else
    redirect_to_page
  end
end

#showObject


23
# File 'app/controllers/admin/page_files_controller.rb', line 23

def show; end

#updateObject


36
37
38
39
40
41
42
43
# File 'app/controllers/admin/page_files_controller.rb', line 36

def update
  flash[:notice] = if @page_file.update(page_file_params)
                     "File updated"
                   else
                     "Error updating file!"
                   end
  redirect_to_page
end