Sha256: 19f4123ecc8a794635de5073b36d402262353866cde560f65cf736348165a1f6

Contents?: true

Size: 825 Bytes

Versions: 14

Compression:

Stored size: 825 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(255)
#  created_at :datetime
#  updated_at :datetime
#

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
enju_biblio-0.2.0.beta.2 app/models/agent_merge_list.rb
enju_biblio-0.2.0.beta.1 app/models/agent_merge_list.rb
enju_biblio-0.1.3 app/models/agent_merge_list.rb
enju_biblio-0.1.2 app/models/agent_merge_list.rb
enju_biblio-0.1.1 app/models/agent_merge_list.rb
enju_biblio-0.1.0 app/models/agent_merge_list.rb
enju_biblio-0.1.0.pre71 app/models/agent_merge_list.rb
enju_biblio-0.1.0.pre70 app/models/agent_merge_list.rb
enju_biblio-0.1.0.pre69 app/models/agent_merge_list.rb
enju_biblio-0.1.0.pre68 app/models/agent_merge_list.rb
enju_biblio-0.1.0.pre67 app/models/agent_merge_list.rb
enju_biblio-0.1.0.pre66 app/models/agent_merge_list.rb
enju_biblio-0.1.0.pre65 app/models/agent_merge_list.rb
enju_biblio-0.1.0.pre64 app/models/agent_merge_list.rb