Sha256: 2c3a6e6595af5a978832f182bc446b07967dbe143eb2156aa36b8c332dd160fe
Contents?: true
Size: 1.27 KB
Versions: 16
Compression:
Stored size: 1.27 KB
Contents
require_dependency 'notee/application_controller' module Notee class TrashesController < ApplicationController before_action :set_trash, only: [:update] 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 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 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 private def get_model case params[:model] when 'posts' return Post when 'categories' return Category when 'images' return Image when 'users' return User when 'comments' return Comment end end def set_trash trash_model = get_model @trash = trash_model.find_by(id: params[:id]) end end end
Version data entries
16 entries across 16 versions & 1 rubygems