Class: Effective::TrashController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Effective::TrashController
- Defined in:
- app/controllers/effective/trash_controller.rb
Instance Method Summary collapse
-
#index ⇒ Object
This is the User index event.
- #restore ⇒ Object
-
#show ⇒ Object
This is the User show event.
Instance Method Details
#index ⇒ Object
This is the User index event
10 11 12 13 14 15 |
# File 'app/controllers/effective/trash_controller.rb', line 10 def index @datatable = Effective::Datatables::Trash.new(user_id: current_user.id) @page_title = 'Trash' EffectiveTrash.(self, :index, Effective::Trash.new(user_id: current_user.id)) end |
#restore ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/effective/trash_controller.rb', line 25 def restore @trash = Effective::Trash.all.find(params[:id]) EffectiveTrash.(self, :update, @trash) Effective::Trash.transaction do begin @trash.restore_trash! @trash.destroy! flash[:success] = "Successfully restored #{@trash}" rescue => e flash[:danger] = "Unable to restore: #{e.}" raise ActiveRecord::Rollback end end redirect_back(fallback_location: effective_trash.trash_path) end |
#show ⇒ Object
This is the User show event
18 19 20 21 22 23 |
# File 'app/controllers/effective/trash_controller.rb', line 18 def show @trash = Effective::Trash.where(user_id: current_user.id).find(params[:id]) @page_title = "Trash item - #{@trash.to_s}" EffectiveTrash.(self, :show, @trash) end |