when remaining costs < $200, pitch harder

This commit is contained in:
Matchu 2015-09-22 22:19:43 -07:00
parent d8038f2fbf
commit 5466cc9301
3 changed files with 18 additions and 3 deletions

View file

@ -26,14 +26,25 @@ module ApplicationHelper
end
end
def cents_to_currency(cents)
number_to_currency(cents / 100.0)
end
def campaign_progress(campaign, &block)
if campaign
if block_given?
content = capture(&block)
else
if campaign.remaining < 200_00
pitch = "We only need #{cents_to_currency(campaign.remaining)} more for #{campaign.name}!"
prompt = "Donate now"
else
pitch = "Help Dress to Impress stay online!"
prompt = "Learn more"
end
content = link_to(
content_tag(:span, 'Help Dress to Impress stay online!') +
content_tag(:span, 'Learn more', :class => 'button'), donate_path)
content_tag(:span, pitch) +
content_tag(:span, prompt, :class => 'button'), donate_path)
end
meter = content_tag(:div, nil, :class => 'campaign-progress',

View file

@ -7,6 +7,10 @@ class Campaign < ActiveRecord::Base
[(progress.to_f / goal) * 100, 100].min
end
def remaining
goal - progress
end
def self.current
self.where(active: true).first or
raise ActiveRecord::RecordNotFound.new("no current campaign")

View file

@ -2,7 +2,7 @@
- if @campaign.progress > 0
= campaign_progress(@campaign) do
We've received #{number_to_currency(@campaign.progress / 100.0)}
We've received #{cents_to_currency(@campaign.progress)}
toward #{@campaign.name}.
Thanks so much!