Class: Pageflow::Editor::FileUsagesController

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

Instance Method Summary collapse

Instance Method Details

#createObject


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

def create
  entry = DraftEntry.find(params[:entry_id])
  file = FileUsage.where(file_usage_params).first!.file

  authorize!(:use, file)
  authorize!(:edit, entry.to_model)
  usage = entry.add_file(file)

  respond_with(:editor, usage)
end

#destroyObject


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

def destroy
  usage = FileUsage.find(params[:id])
  entry = DraftEntry.for_file_usage(usage)

  authorize!(:edit, entry.to_model)
  verify_edit_lock!(entry)
  entry.remove_file(usage.file)

  head(:no_content)
end