Class: Campaign
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Campaign
- Defined in:
- app/models/entities/campaign.rb
Overview
Copyright © 2008-2013 Michael Dvorkin and contributors.
Fat Free CRM is freely distributable under the terms of MIT license. See MIT-LICENSE file or www.opensource.org/licenses/mit-license.php
Schema Information
Table name: campaigns
id :integer not null, primary key
user_id :integer
assigned_to :integer
name :string(64) default(""), not null
access :string(8) default("Public")
status :string(64)
budget :decimal(12, 2)
target_leads :integer
target_conversion :float
target_revenue :decimal(12, 2)
leads_count :integer
opportunities_count :integer
revenue :decimal(12, 2)
starts_on :date
ends_on :date
objectives :text
deleted_at :datetime
created_at :datetime
updated_at :datetime
background_info :string(255)
Class Method Summary collapse
-
.per_page ⇒ Object
Default values provided through class methods.
Instance Method Summary collapse
-
#attach!(attachment) ⇒ Object
Attach given attachment to the campaign if it hasn’t been attached already.
-
#discard!(attachment) ⇒ Object
Discard given attachment from the campaign.
Class Method Details
.per_page ⇒ Object
Default values provided through class methods.
72 73 74 |
# File 'app/models/entities/campaign.rb', line 72 def self.per_page 20 end |
Instance Method Details
#attach!(attachment) ⇒ Object
Attach given attachment to the campaign if it hasn’t been attached already.
78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/models/entities/campaign.rb', line 78 def attach!() unless send("#{.class.name.downcase}_ids").include?(.id) if .is_a?(Task) send(.class.name.tableize) << else # Leads, Opportunities .update_attribute(:campaign, self) .send("increment_#{.class.name.tableize}_count") [] end end end |
#discard!(attachment) ⇒ Object
Discard given attachment from the campaign.
92 93 94 95 96 97 98 99 |
# File 'app/models/entities/campaign.rb', line 92 def discard!() if .is_a?(Task) .update_attribute(:asset, nil) else # Leads, Opportunities .send("decrement_#{.class.name.tableize}_count") .update_attribute(:campaign, nil) end end |