Class: SearchAction
- Inherits:
-
Object
- Object
- SearchAction
- Defined in:
- app/controllers/admin_data/search_controller.rb
Instance Attribute Summary collapse
-
#relation ⇒ Object
Returns the value of attribute relation.
-
#success_message ⇒ Object
Returns the value of attribute success_message.
Instance Method Summary collapse
- #delete ⇒ Object
- #destroy ⇒ Object
-
#initialize(relation) ⇒ SearchAction
constructor
A new instance of SearchAction.
Constructor Details
#initialize(relation) ⇒ SearchAction
Returns a new instance of SearchAction.
4 5 6 |
# File 'app/controllers/admin_data/search_controller.rb', line 4 def initialize(relation) @relation = relation end |
Instance Attribute Details
#relation ⇒ Object
Returns the value of attribute relation.
2 3 4 |
# File 'app/controllers/admin_data/search_controller.rb', line 2 def relation @relation end |
#success_message ⇒ Object
Returns the value of attribute success_message.
2 3 4 |
# File 'app/controllers/admin_data/search_controller.rb', line 2 def end |
Instance Method Details
#delete ⇒ Object
8 9 10 11 12 |
# File 'app/controllers/admin_data/search_controller.rb', line 8 def delete count = relation.count relation.delete_all self. = "#{count} #{AdminData::Util.pluralize(count, 'record')} deleted" end |
#destroy ⇒ Object
14 15 16 17 18 19 20 |
# File 'app/controllers/admin_data/search_controller.rb', line 14 def destroy count = relation.count relation.find_in_batches do |group| group.each {|record| record.destroy } end self. = "#{count} #{AdminData::Util.pluralize(count, 'record')} destroyed" end |