referrals [under development - not yet production ready]
Referrals engine dedicated for Ruby on Rails based applications
Short description and motivation.
How to use my plugin.
Add this line to your application's Gemfile:
And then execute:
After that run:
It will copy engine's migrations to your project. Now migrate:
# Rails 4 bin/rake db:migrate # Rails 5 bin/rails db:migrate
Integration with Rails
Handling referral cookies
# in your controller where you want to have cookies handling available class ApplicationController < ActionController::Base include Referrals::CookiesConcern # ... end
Assigning referrals to partner
# in your controller where you want to assign user to partner class RegistrationsController < ActionController::Base include Referrals::OperationsConcern # ... def register # eg: assign referrals to partner when user # just registered # Now resource under 'registered_user' will be assigned to partner # based on value in cookie assign_referral_to_partner(registered_user) end end
Capturing referral action
# in your controller where you want to capture referral action class PaymentController < ActionController::Base # 1. First: include operations module include Referrals::OperationsConcern def make_payment #2. Second: capture action made by user eg: payment for subscription # This way operation will be captured and proper amount will be added # To partner's account. capture_referral_action(referral: current_user, amount: Money.new(1030), info: 'Payment for subscription') # ... render plain: 'ok' end end
Rescue from errors
Contribution directions go here.
The gem is available as open source under the terms of the MIT License.