1
0
Fork 0
forked from OpenNeo/impress

thank-you message automatically deploys on campaign success

This commit is contained in:
Matchu 2015-09-22 22:40:51 -07:00
parent 5466cc9301
commit 2ca784c3a2
4 changed files with 13 additions and 1 deletions

View file

@ -11,6 +11,10 @@ class Campaign < ActiveRecord::Base
goal - progress
end
def complete?
progress >= goal
end
def self.current
self.where(active: true).first or
raise ActiveRecord::RecordNotFound.new("no current campaign")

View file

@ -26,6 +26,8 @@
= text_field_tag 'donation[amount]', '10.00'
%button{:type => 'submit'} Donate now!
- if @campaign.complete? && @campaign.thanks?
#success-thanks= emote_md @campaign.thanks
#description= emote_md @campaign.description
- if @donations.present?

View file

@ -0,0 +1,5 @@
class AddThanksToCampaign < ActiveRecord::Migration
def change
add_column :campaigns, :thanks, :text
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20150905181350) do
ActiveRecord::Schema.define(:version => 20150923052017) do
create_table "auth_servers", :force => true do |t|
t.string "short_name", :limit => 10, :null => false
@ -42,6 +42,7 @@ ActiveRecord::Schema.define(:version => 20150905181350) do
t.text "description", :null => false
t.string "name", :default => "our hosting costs this year", :null => false
t.string "theme_id", :default => "hug", :null => false
t.text "thanks"
end
create_table "campaigns_old", :force => true do |t|