2015-08-05 16:26:12 -07:00
|
|
|
class CampaignsController < ApplicationController
|
|
|
|
def show
|
|
|
|
@campaign = Campaign.find(params[:id])
|
|
|
|
redirect_to(action: :current) if @campaign.active?
|
2018-01-18 17:14:02 -08:00
|
|
|
@current_campaign = Campaign.current
|
2015-08-05 16:26:12 -07:00
|
|
|
@donations = find_donations
|
2017-01-05 13:06:50 -08:00
|
|
|
@all_campaigns = find_all_campaigns
|
2015-08-05 16:26:12 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
def current
|
|
|
|
@campaign = Campaign.current
|
2018-01-18 17:14:02 -08:00
|
|
|
@current_campaign = @campaign
|
2015-08-05 16:26:12 -07:00
|
|
|
@donations = find_donations
|
2017-01-05 13:06:50 -08:00
|
|
|
@all_campaigns = find_all_campaigns
|
2015-08-05 16:26:12 -07:00
|
|
|
render action: :show
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2017-01-05 13:06:50 -08:00
|
|
|
def find_all_campaigns
|
|
|
|
@all_campaigns = Campaign.order('created_at DESC').all
|
|
|
|
end
|
|
|
|
|
2015-08-05 16:26:12 -07:00
|
|
|
def find_donations
|
2017-01-05 13:06:50 -08:00
|
|
|
@campaign.donations.includes(features: :outfit).order('created_at DESC')
|
2015-08-05 16:26:12 -07:00
|
|
|
end
|
|
|
|
end
|