Class: PatronMergeList

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/patron_merge_list.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.per_pageObject



7
8
9
# File 'app/models/patron_merge_list.rb', line 7

def self.per_page
  10
end

Instance Method Details

#merge_patrons(selected_patron) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'app/models/patron_merge_list.rb', line 11

def merge_patrons(selected_patron)
  self.patrons.each do |patron|
    Create.update_all(['patron_id = ?', selected_patron.id], ['patron_id = ?', patron.id])
    Produce.update_all(['patron_id = ?', selected_patron.id], ['patron_id = ?', patron.id])
    Own.update_all(['patron_id = ?', selected_patron.id], ['patron_id = ?', patron.id])
    Donate.update_all(['patron_id = ?', selected_patron.id], ['patron_id = ?', patron.id])
    patron.destroy unless patron == selected_patron
  end
end