Class: Notee::TrashesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/notee/trashes_controller.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationController

#restrict_access_json, #set_request_filter

Class Method Details

.cleanupObject



30
31
32
33
34
35
36
# File 'app/controllers/notee/trashes_controller.rb', line 30

def self.cleanup
	Post.trash.time_limit.delete_all
	Category.trash.time_limit.delete_all
	Image.trash.time_limit.delete_all
	User.trash.time_limit.delete_all
	Comment.trash.time_limit.delete_all
end

Instance Method Details

#indexObject



7
8
9
10
11
12
13
14
# File 'app/controllers/notee/trashes_controller.rb', line 7

def index
	trash_model = get_model
	if @trashes = trash_model.trash
		render json: { status: 'success', trashes: @trashes }
	else
		render json: @trashes.errors, status: 422
	end
end

#updateObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/notee/trashes_controller.rb', line 16

def update
	get_model.skip_callback(:update, :before, :update_authority)

	respond_to do |format|
		if @trash.update(is_deleted: false)
			format.json { render json: @trash, status: 200 }
		else
			format.json { render json: @trash.errors, status: :unprocessable_entity }
		end
	end

	get_model.set_callback(:update, :before, :update_authority)
end