lib/typus/controller/trash.rb in typus-3.1.0.rc6 vs lib/typus/controller/trash.rb in typus-3.1.0.rc7

- old
+ new

@@ -1,5 +1,11 @@ +## +# This module is designed to work with `rails-trash`. Add it to your `Gemfile` +# if you have plans to use it: +# +# gem "rails-trash", "~> 1.1.1" +# module Typus module Controller module Trash def self.included(base) @@ -17,31 +23,29 @@ get_objects respond_to do |format| format.html do # Actions by resource. - add_resource_action('Restore', {:action => 'restore'}, {:confirm => Typus::I18n.t("Restore %{resource}?", :resource => @resource.model_name.human)}) - add_resource_action('Delete Permanently', {:action => 'wipe'}, {:confirm => Typus::I18n.t("Delete Permanently %{resource}?", :resource => @resource.model_name.human)}) + add_resource_action 'Restore', { :action => 'restore' }, { :confirm => Typus::I18n.t("Restore %{resource}?", :resource => @resource.model_name.human) } + add_resource_action 'Delete Permanently', { :action => 'wipe' }, { :confirm => Typus::I18n.t("Delete Permanently?") } # Generate and render. generate_html render 'index' end %w(json xml csv).each { |f| format.send(f) { send("generate_#{f}") } } end end def restore - set_deleted - @resource.find(params[:id]).restore + @resource.restore(params[:id]) redirect_to :back, :notice => Typus::I18n.t("%{resource} recovered from trash.", :resource => @resource.name) rescue ActiveRecord::RecordNotFound redirect_to :back, :notice => Typus::I18n.t("%{resource} can't be recovered from trash.", :resource => @resource.name) end def wipe - set_deleted - item = @resource.find(params[:id]) + item = @resource.find_in_trash(params[:id]) item.disable_trash { item.destroy } redirect_to :back, :notice => Typus::I18n.t("%{resource} has been successfully removed from trash.", :resource => @resource.name) end def set_deleted