Class: Effective::AssetsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/effective/assets_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject



27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/effective/assets_controller.rb', line 27

def destroy
  @asset = Effective::Asset.find(params[:id])
  EffectiveAssets.authorized?(self, :destroy, @asset)

  if @asset.destroy
    flash[:success] = 'Successfully deleted asset'
  else
    flash[:danger] = 'Unable to delete asset'
  end

  redirect_to(:back) rescue redirect_to(effective_assets.effective_assets_path)
end

#indexObject

This is the Modal dialog that is read by CKEDITOR



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/effective/assets_controller.rb', line 7

def index  # This is the Modal dialog that is read by CKEDITOR
  EffectiveAssets.authorized?(self, :index, Effective::Asset.new(:user_id => current_user.try(:id)))

  @assets =  Effective::Asset.where(:user_id => current_user.try(:id))
  @aws_acl = EffectiveAssets.aws_acl.presence || 'public-read'

  if params[:only] == 'images'
    @assets = @assets.images
    @file_types = [:jpg, :gif, :png, :bmp, :ico]
    @aws_acl = 'public-read' # The CKEditor Insert Image functionality needs a public-read image here
  elsif params[:only] == 'nonimages'
    @assets = @assets.nonimages
    @file_types = [:pdf, :zip, :doc, :docx, :xls, :xlsx, :txt, :avi, :m4v, :m2v, :mov, :mp3, :mp4]
  end

  @user_uploads = UserUploads.new(@assets)

  render :file => 'effective/assets/iframe'
end