Sha256: a2b6585fe472f22e5173d7255b27b10083d225eff410d5fceb60a57d503f408e
Contents?: true
Size: 1.21 KB
Versions: 4
Compression:
Stored size: 1.21 KB
Contents
module Effective class TrashController < ApplicationController before_action :authenticate_user! # This is the User index event def index @datatable = EffectiveTrashDatatable.new(self, user_id: current_user.id) @page_title = 'Trash' EffectiveTrash.authorize!(self, :index, Effective::Trash.new(user_id: current_user.id)) end # This is the User show event def show @trash = Effective::Trash.where(user_id: current_user.id).find(params[:id]) @page_title = "Trash item - #{@trash.to_s}" EffectiveTrash.authorize!(self, :show, @trash) end def restore @trash = Effective::Trash.find(params[:id]) EffectiveTrash.authorize!(self, :update, @trash) Effective::Trash.transaction do begin @trash.restore! flash[:success] = "Successfully restored #{@trash}" rescue => e flash[:danger] = "Unable to restore: #{e.message}" raise ActiveRecord::Rollback end end if request.referer.to_s.include?(effective_trash.admin_trash_index_path) redirect_to effective_trash.admin_trash_index_path else redirect_to effective_trash.trash_index_path end end end end
Version data entries
4 entries across 4 versions & 1 rubygems