Module: Archivable::Controller
- Extended by:
- ActiveSupport::Concern
- Includes:
- MetaMagic::Controller
- Defined in:
- lib/archivable/controller.rb
Instance Method Summary collapse
Instance Method Details
#archive ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/archivable/controller.rb', line 9 def archive archivable_model = set_model_instance_variable archivable_model.toggle(:archived) if archivable_model.save redirect_to action: :show else render :edit end end |
#archived ⇒ Object
20 21 22 23 24 |
# File 'lib/archivable/controller.rb', line 20 def archived instance_variable_set(:"@#{ controller_name }", policy_scope(get_model_class).where(archived: true)) render :index end |
#get_archivable_flash(model, opts = {}) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/archivable/controller.rb', line 26 def get_archivable_flash(model, opts = {}) "#{ model.class.name } was"\ "#{ ' not' unless opts[:success] } "\ "#{ model.archived ? :archived : :unarchived } "\ "successfully." end |