impress/app/controllers/campaigns_controller.rb

28 lines
674 B
Ruby
Raw Normal View History

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?
@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
@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