Sha256: daf5df290482728b93677df13acd0bafdc500d39ca4730d08ad8cd4e4872b37e
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 KB
Contents
module Effective class TrashController < ApplicationController if respond_to?(:before_action) # Devise before_action :authenticate_user! else before_filter :authenticate_user! end # This is the User index event def index @datatable = Effective::Datatables::Trash.new(user_id: current_user.id) @page_title = 'Trash' EffectiveLogging.authorized?(self, :restore, Effective::Log.new(user_id: current_user.id)) end # This is the User show event def show @trash = Effective::Log.trash.find(params[:id]) @page_title = "Trash item - #{@trash.to_s}" EffectiveLogging.authorized?(self, :restore, @trash) end def restore @trash = Effective::Log.trash.find(params[:id]) EffectiveLogging.authorized?(self, :restore, @trash) Effective::Log.transaction do begin @trash.restore_trashable! @trash.destroy! flash[:success] = "Successfully restored #{@trash}" rescue => e flash[:danger] = "Unable to restore: #{e.message}" raise ActiveRecord::Rollback end end redirect_back(fallback_location: effective_logging.trash_path) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
effective_logging-1.7.1 | app/controllers/effective/trash_controller.rb |
effective_logging-1.7.0 | app/controllers/effective/trash_controller.rb |