From 3d1fac1655e51d08d77ff4405c4e6966289cecf5 Mon Sep 17 00:00:00 2001 From: Eric Schultz Date: Wed, 6 Feb 2019 11:24:37 -0600 Subject: [PATCH] Nonprofit page now only shows non-child campaigns --- app/controllers/nonprofits_controller.rb | 2 +- app/models/campaign.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/nonprofits_controller.rb b/app/controllers/nonprofits_controller.rb index 9a78baf9..d33e46a4 100755 --- a/app/controllers/nonprofits_controller.rb +++ b/app/controllers/nonprofits_controller.rb @@ -19,7 +19,7 @@ @profiles = @nonprofit.profiles.order('total_raised DESC').limit(5).includes(:user).uniq events = @nonprofit.events.not_deleted.order('start_datetime desc') - campaigns = @nonprofit.campaigns.not_deleted.order('created_at desc') + campaigns = @nonprofit.campaigns.not_deleted.not_a_child.order('created_at desc') @events = events.upcoming @any_past_events = events.past.any? diff --git a/app/models/campaign.rb b/app/models/campaign.rb index c4c64669..f0d62fcc 100644 --- a/app/models/campaign.rb +++ b/app/models/campaign.rb @@ -76,6 +76,7 @@ class Campaign < ActiveRecord::Base scope :unpublished, -> {where(:published => [nil, false])} scope :not_deleted, -> {where(deleted: [nil, false])} scope :deleted, -> {where(deleted: true)} + scope :not_a_child, -> {where(parent_campaign_id: nil)} before_validation do if self.goal_amount_dollars.present?