Sha256: 0d272a32388b7e3de5788e557d32d848ad4d67e9d8be7585cfba1ad6421cfd4f

Contents?: true

Size: 1.12 KB

Versions: 27

Compression:

Stored size: 1.12 KB

Contents

module Workarea
  module Admin
    class CustomEventsController < Admin::ApplicationController
      before_action :find_event

      def create
        @custom_event.save!
        flash[:success] = t('workarea.admin.reports.timeline.flash_messages.created')
        redirect_back fallback_location: root_path
      end

      def update
        if @custom_event.update(params[:custom_event])
          flash[:success] =
            t('workarea.admin.reports.timeline.flash_messages.success')
        else
          flash[:error] =
            t('workarea.admin.reports.timeline.flash_messages.error')
        end

        redirect_back fallback_location: root_path
      end

      def destroy
        @custom_event.destroy
        flash[:success] = t('workarea.admin.reports.timeline.flash_messages.success')
        redirect_back fallback_location: root_path
      end

      private

      def find_event
        @custom_event = if params[:id].present?
          Workarea::Reports::CustomEvent.find_by(id: params[:id])
        else
          Workarea::Reports::CustomEvent.new(params[:custom_event])
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
workarea-admin-3.5.6 app/controllers/workarea/admin/custom_events_controller.rb
workarea-admin-3.5.5 app/controllers/workarea/admin/custom_events_controller.rb
workarea-admin-3.5.4 app/controllers/workarea/admin/custom_events_controller.rb
workarea-admin-3.5.3 app/controllers/workarea/admin/custom_events_controller.rb
workarea-admin-3.5.2 app/controllers/workarea/admin/custom_events_controller.rb
workarea-admin-3.5.1 app/controllers/workarea/admin/custom_events_controller.rb
workarea-admin-3.5.0 app/controllers/workarea/admin/custom_events_controller.rb