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.3.8 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.3.7 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.3.6 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.3.5 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.3.4 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.3.3 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.3.2 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.3.1 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.3.0 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.2.7 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.2.6 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.1.10 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.0.10 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-4.6.7 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.2.5 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.1.9 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.0.9 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-4.6.6 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.2.4 app/controllers/alchemy/admin/essence_files_controller.rb
alchemy_cms-5.1.8 app/controllers/alchemy/admin/essence_files_controller.rb