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



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/pageflow/editor/files_controller.rb', line 19

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

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

  @model_name = model_name
  @collection_name = collection_name.to_s

  respond_with(:editor, @file)
end

#indexObject



8
9
10
11
12
13
14
15
16
17
# 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.send(collection_name).with_usage_id
  @model_name = model_name
  @collection_name = collection_name.to_s

  respond_with(:editor, @files)
end

#retryObject



33
34
35
36
37
38
39
40
41
# File 'app/controllers/pageflow/editor/files_controller.rb', line 33

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

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

  respond_with(:editor, file)
end

#updateObject



43
44
45
46
47
48
49
50
51
# File 'app/controllers/pageflow/editor/files_controller.rb', line 43

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

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

  head(:no_content)
end