Skip to content

Instantly share code, notes, and snippets.

@notch8-old
Forked from etdebruin/campaign.rb
Created August 27, 2011 00:31
Show Gist options
  • Save notch8-old/1174776 to your computer and use it in GitHub Desktop.
Save notch8-old/1174776 to your computer and use it in GitHub Desktop.
Campaign
class Campaign < ActiveRecord::Base
belongs_to :user
#scope :active, where(:active => true)
#scope :not_yet_active, where(:active => false)
validates :goal, :presence => true
validates :url, :presence => true
validates :name_or_twitter, :presence => true
attr_accessor :complete_tweet
def complete_tweet
@complete_tweet ||= if self.campaign_url
"#{self.tweet} #{self.campaign_url} #{MyGivingTweetConf::HASHTAG}"
else
"#{self.tweet} http://bit.ly/XXXXX #{MyGivingTweetConf::HASHTAG}"
end
end
ruby-1.9.2-p290 :002 > c.full_tweet
=> "I am excited to donate $500 to @hrrygggg and you should consider helping me http://bit.ly/XXXXX #mgt20yo http://bit.ly/XXXXX #mgt20yo"
ruby-1.9.2-p290 :003 > c.complete_tweet
=> "I am excited to donate $500 to @hrrygggg and you should consider helping me http://bit.ly/XXXXX #mgt20yo http://bit.ly/XXXXX #mgt20yo"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment