Module: Typus::Controller::Trash
- Defined in:
- lib/typus/controller/trash.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
6 7 8 |
# File 'lib/typus/controller/trash.rb', line 6 def self.included(base) base.before_filter :set_predefined_filter_for_trash, :only => [:index, :trash] end |
Instance Method Details
#restore ⇒ Object
38 39 40 41 42 43 |
# File 'lib/typus/controller/trash.rb', line 38 def 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 |
#trash ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/typus/controller/trash.rb', line 17 def trash set_deleted 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?") } # Generate and render. generate_html render 'index' end format.csv { generate_csv } format.json { export(:json) } format.xml { export(:xml) } end end |
#wipe ⇒ Object
45 46 47 48 49 |
# File 'lib/typus/controller/trash.rb', line 45 def wipe 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 |