app/models/entities/campaign.rb
def attach!(attachment)
    unless self.send("#{attachment.class.name.downcase}_ids").include?(attachment.id)
      if attachment.is_a?(Task)
        self.send(attachment.class.name.tableize) << attachment
      else # Leads, Opportunities
        attachment.update_attribute(:campaign, self)
        attachment.send("increment_#{attachment.class.name.tableize}_count")
        [ attachment ]
      end
    end
  end
# Attach given attachment to the campaign if it hasn't been attached already.
#----------------------------------------------------------------------------
Attach given attachment to the campaign if it hasn't been attached already.
Attach given attachment to the campaign if it hasn ' t been attached already .
def attach!(attachment)
    unless self.send("#{attachment.class.name.downcase}_ids").include?(attachment.id)
      if attachment.is_a?(Task)
        self.send(attachment.class.name.tableize) << attachment
      else 
        attachment.update_attribute(:campaign, self)
        attachment.send("increment_#{attachment.class.name.tableize}_count")
        [ attachment ]
      end
    end
  end
def attach! ( attachment ) unless self . send ( "#{attachment.class.name.downcase}_ids" ) . include? ( attachment . id ) if attachment . is_a? ( Task ) self . send ( attachment . class . name . tableize ) << attachment else attachment . update_attribute ( :campaign , self ) attachment . send ( "increment_#{attachment.class.name.tableize}_count" ) [ attachment ] end end end
Attach given attachment to the campaign if it hasn't been attached already.
Attach given attachment to the campaign if it hasn ' t been attached already .
# Leads, Opportunities
attachment