Sha256: 417260c94a823ce239d52abf842a0383299a035d680b6a8b7700026344104c69

Contents?: true

Size: 1.13 KB

Versions: 78

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module Alchemy
  module Admin
    class EssenceFilesController < Alchemy::Admin::BaseController
      authorize_resource class: Alchemy::EssenceFile

      before_action :load_essence_file, only: [:edit, :update]

      helper "Alchemy::Admin::Contents"

      def edit
        @content = @essence_file.content
      end

      def update
        @essence_file.update(essence_file_params)
      end

      # Assigns file, but does not saves it.
      #
      # When the user saves the element the content gets updated as well.
      #
      def assign
        @content = Content.find_by(id: params[:content_id])
        @attachment = Attachment.find_by(id: params[:attachment_id])
        @content.essence.attachment = @attachment

        # We need to update timestamp here because we don't save yet,
        # but the cache needs to be get invalid.
        @content.touch
      end

      private

      def essence_file_params
        params.require(:essence_file).permit(:title, :css_class, :link_text)
      end

      def load_essence_file
        @essence_file = EssenceFile.find(params[:id])
      end
    end
  end
end

Version data entries

78 entries across 78 versions & 1 rubygems

Version Path
alchemy_cms-5.0.8 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-4.6.5 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-4.5.1 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-4.4.5 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-4.6.4 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.0.7 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.1.7 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.2.3 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.1.6 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.0.6 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.2.2 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.1.5 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.0.5 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.2.1 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.1.4 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-4.6.3 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.0.4 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.1.3 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.2.0 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.2.0.rc1 app/controllers/alchemy/admin/essence_files_controller.rb