Sha256: 47258ab30e300ead2fc6a2d5c3ff13a043f7da21ff9a0fbcc2368ec8dd19c8c3

Contents?: true

Size: 820 Bytes

Versions: 15

Compression:

Stored size: 820 Bytes

Contents

class AgentMergeList < ActiveRecord::Base
  has_many :agent_merges, dependent: :destroy
  has_many :agents, through: :agent_merges
  validates_presence_of :title

  paginates_per 10

  def merge_agents(selected_agent)
    self.agents.each do |agent|
      Create.where(agent_id: selected_agent.id).update_all(agent_id: agent.id)
      Produce.where(agent_id: selected_agent.id).update_all(agent_id: agent.id)
      Own.where(agent_id: selected_agent.id).update_all(agent_id: agent.id)
      Donate.where(agent_id: selected_agent.id).update_all(agent_id: agent.id)
      agent.destroy unless agent == selected_agent
    end
  end
end

# == Schema Information
#
# Table name: agent_merge_lists
#
#  id         :integer          not null, primary key
#  title      :string
#  created_at :datetime
#  updated_at :datetime
#

Version data entries

15 entries across 14 versions & 2 rubygems

Version Path
enju_biblio-0.3.2 app/models/agent_merge_list.rb
enju_biblio-0.3.1 app/models/agent_merge_list.rb
enju_biblio-0.3.0 app/models/agent_merge_list.rb
enju_biblio-0.3.0.rc.1 app/models/agent_merge_list.rb
enju_biblio-0.3.0.beta.2 app/models/agent_merge_list.rb
enju_biblio-0.2.5 app/models/agent_merge_list.rb
enju_biblio-0.2.4 app/models/agent_merge_list.rb
enju_biblio-0.2.3 app/models/agent_merge_list.rb
enju_biblio-0.2.2 app/models/agent_merge_list.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/enju_biblio-0.2.1/app/models/agent_merge_list.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/enju_biblio-0.2.0/app/models/agent_merge_list.rb
enju_biblio-0.2.1 app/models/agent_merge_list.rb
enju_biblio-0.2.0 app/models/agent_merge_list.rb
enju_biblio-0.2.0.beta.4 app/models/agent_merge_list.rb
enju_biblio-0.2.0.beta.3 app/models/agent_merge_list.rb