Class: Pageflow::Editor::FilesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/pageflow/editor/files_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/pageflow/editor/files_controller.rb', line 17

def create
  entry = DraftEntry.find(params[:entry_id])
  authorize!(:edit, entry.to_model)
  verify_edit_lock!(entry)

  @file = entry.create_file(file_type.model, file_params)
  @file.publish!

  respond_with(:editor, @file)
end

#indexObject



8
9
10
11
12
13
14
15
# File 'app/controllers/pageflow/editor/files_controller.rb', line 8

def index
  entry = DraftEntry.find(params[:entry_id])

  authorize!(:use_files, entry.to_model)
  @files = entry.files(file_type.model)

  respond_with(:editor, @files)
end

#retryObject



28
29
30
31
32
33
34
35
36
# File 'app/controllers/pageflow/editor/files_controller.rb', line 28

def retry
  file = file_type.model.find(params[:id])

  authorize!(:retry, file)
  verify_edit_lock!(file.entry)
  file.retry!

  respond_with(:editor, file, location: editor_file_url(file, collection_name: params[:collection_name]))
end

#updateObject



38
39
40
41
42
43
44
45
46
# File 'app/controllers/pageflow/editor/files_controller.rb', line 38

def update
  file = file_type.model.find(params[:id])

  authorize!(:update, file)
  verify_edit_lock!(file.entry)
  file.update_attributes!(update_params)

  head(:no_content)
end