Class: Account::ReferralsController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- ApplicationController
- BaseController
- Account::ReferralsController
- Defined in:
- app/controllers/account/referrals_controller.rb
Instance Method Summary collapse
- #cash_out ⇒ Object
- #create ⇒ Object
- #data ⇒ Object
- #index ⇒ Object
- #resend_email ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
caches_page_with_cache_marker, #raise_not_found!
Instance Method Details
#cash_out ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'app/controllers/account/referrals_controller.rb', line 71 def cash_out amount = params[:amount].to_f if amount > 0 @coupon = TranslationCms::Api::Customers::Discounts::PersonalCoupon .create(discount: { amount: amount }) end respond_to do |format| format.json { render } format.all { raise ActiveRecord::RecordNotFound, 'Sorry' } end end |
#create ⇒ Object
52 53 54 55 56 57 |
# File 'app/controllers/account/referrals_controller.rb', line 52 def create @form = AffiliateProgram::RegistrationForm.new(params[:member]) @form.submit if @form.valid? respond_with @form, location: account_referrals_path end |
#data ⇒ Object
40 41 42 43 |
# File 'app/controllers/account/referrals_controller.rb', line 40 def data @industry_expertises = TranslationCms::Api::IndustryExpertise.all! @countries = TranslationCms::Country.all end |
#index ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/account/referrals_controller.rb', line 13 def index @member = begin TranslationCms::Api::Customers::AffiliateProgram::Member.profile.first rescue StandardError nil end if @member&.registered? # params[:q] = params[:q].to_i # params.delete(:q) if params[:g].blank? || params[:g]<=0 @structure = ContentStorageType.affiliate_registered.storage @commissions = Kaminari.paginate_array( TranslationCms::Api::Customers::AffiliateProgram::Commission.where(filter_params) ).page(params[:page]).per(params[:per]) params.merge! filter_params # @m_params = params.dup() # @m_params[:per] = 2 # @m_commissions = @commissions.per(2) else @structure = ContentStorageType.affiliate_new_customer.storage end respond_with @member end |
#resend_email ⇒ Object
66 67 68 69 |
# File 'app/controllers/account/referrals_controller.rb', line 66 def resend_email @member = TranslationCms::Api::Customers::AffiliateProgram::Member.resend respond_with @member, location: account_referrals_path end |
#show ⇒ Object
45 46 47 48 49 50 |
# File 'app/controllers/account/referrals_controller.rb', line 45 def show @member = TranslationCms::Api::Customers::AffiliateProgram::Member.confirm( confirmation_token: params[:id] ) redirect_to account_referrals_path end |
#update ⇒ Object
59 60 61 62 63 64 |
# File 'app/controllers/account/referrals_controller.rb', line 59 def update @form = AffiliateProgram::MemberForm.new(params[:member]) @form.submit if @form.valid? respond_with @form, location: account_referrals_path end |