diff --git a/app/models/campaign.rb b/app/models/campaign.rb index 6bc11bec..c54b9595 100644 --- a/app/models/campaign.rb +++ b/app/models/campaign.rb @@ -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") diff --git a/app/views/campaigns/show.html.haml b/app/views/campaigns/show.html.haml index 099f156d..e3de474d 100644 --- a/app/views/campaigns/show.html.haml +++ b/app/views/campaigns/show.html.haml @@ -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? diff --git a/db/migrate/20150923052017_add_thanks_to_campaign.rb b/db/migrate/20150923052017_add_thanks_to_campaign.rb new file mode 100644 index 00000000..bf089442 --- /dev/null +++ b/db/migrate/20150923052017_add_thanks_to_campaign.rb @@ -0,0 +1,5 @@ +class AddThanksToCampaign < ActiveRecord::Migration + def change + add_column :campaigns, :thanks, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 0ece6bf6..e72a496d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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|