Sha256: f57480b21ac7e0dc0178bc27cea64815651669990a8d3246c55b4f4f87b1b22e

Contents?: true

Size: 1.02 KB

Versions: 8

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

class Ckeditor::AttachmentFilesController < Ckeditor::ApplicationController
  skip_before_action :verify_authenticity_token, only: :create, raise: false

  def index
    @attachments = Ckeditor.attachment_file_adapter.find_all(ckeditor_attachment_files_scope)
    @attachments = Ckeditor::Paginatable.new(@attachments).page(params[:page])

    respond_to do |format|
      format.html { render layout: @attachments.first_page? }
    end
  end

  def create
    @attachment = Ckeditor.attachment_file_model.new
    respond_with_asset(@attachment)
  end

  def destroy
    @attachment.destroy

    respond_to do |format|
      format.html { redirect_to attachment_files_path }
      format.json { render json: @attachment, status: 204 }
    end
  end

  protected

  def find_asset
    @attachment = Ckeditor.attachment_file_adapter.get!(params[:id])
  end

  def authorize_resource
    model = (@attachment || Ckeditor.attachment_file_model)
    @authorization_adapter.try(:authorize, params[:action], model)
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
ckeditor-5.1.3 app/controllers/ckeditor/attachment_files_controller.rb
ckeditor-5.1.2 app/controllers/ckeditor/attachment_files_controller.rb
ckeditor-5.1.1 app/controllers/ckeditor/attachment_files_controller.rb
glebtv-ckeditor-4.14.1 app/controllers/ckeditor/attachment_files_controller.rb
ckeditor-5.1.0 app/controllers/ckeditor/attachment_files_controller.rb
glebtv-ckeditor-4.13.1 app/controllers/ckeditor/attachment_files_controller.rb
glebtv-ckeditor-4.13.0 app/controllers/ckeditor/attachment_files_controller.rb
ckeditor-5.0.0 app/controllers/ckeditor/attachment_files_controller.rb