Class: Gold::Admin::ReferralsController
- Inherits:
-
AdminController
- Object
- ActionController::Base
- Gold::ApplicationController
- AdminController
- Gold::Admin::ReferralsController
- Defined in:
- app/controllers/gold/admin/referrals_controller.rb
Overview
Controller for referrals
Instance Method Summary collapse
Instance Method Details
#add_billing ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/gold/admin/referrals_controller.rb', line 41 def add_billing referral = Referral.find_by(id: params[:referral_id]) billing = Billing.find(params[:id]) billing.update(referral: referral) flash[:success] = "Updated referral" redirect_back(fallback_location: "/admin") end |
#create ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/controllers/gold/admin/referrals_controller.rb', line 5 def create referral = Referral.new(referral_params) if referral.save flash[:success] = "Created new referrer" else = referral.errors..join(", ") flash[:danger] = "Failed to create, #{}" end redirect_to "#{request.path}/#{referral.id}" end |
#delete ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/gold/admin/referrals_controller.rb', line 31 def delete referral = Referral.find(params[:id]) referral.destroy! flash[:success] = "Poof! Code #{referral.code} no longer exists" redirect_to gold_admin_engine.referrals_path end |
#update ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/gold/admin/referrals_controller.rb', line 18 def update referral = Referral.find(params[:id]) if referral.update(referral_params) flash[:success] = "Update referrer" else = referral.errors..join(", ") flash[:danger] = "Failed to update, #{}" end redirect_back(fallback_location: "/admin") end |