devise_referable

Adds the ability to track registrations that were referred from partners

4 years after

= devise_referable

It adds support to devise[http://github.com/plataformatec/devise] for tracking users that were sent by referrers modeled as other classes in your app and allows multiple people to be reffered by the same person. In addition, accepting an invitation recorded in a cooky so it is not necesary to create a separate acceptance page. You can provide any page to be acceptance page

== Installation

All gems are on gemcutter, so you need to add gemcutter to your sources if you haven’t yet:

sudo gem sources -a http://gemcutter.org/

Install devise_referable gem, it should install dependencies (such as devise and warden):

sudo gem install devise_referable

Configure devise_referable inside your app (and warden and devise if you weren't using them):

config.gem 'warden' config.gem 'devise' config.gem 'devise_referable'

== Basic Usage

Follow the walkthrough for devise with the following modifications.

Create a migration for the referrals table, minimally:

create_table :referrals, :force => true do |t|
  t.integer   :referrer_id
  t.string    :referrer_type
  t.integer   :recipient_id
  t.string    :referral_token
  t.datetime  :registered_at
  t.string    :session_id
  t.timestamps
end

And create a Referral class, minimally:

class Referral < ActiveRecord::Base
    acts_as_referral
end

Add a referrer_token column to your referrer classes.

add_column :table_name1, :referrer_token, :string
add_column :table_name2, :referrer_token, :string

Add indexes if you want add_index :referrals, :referral_token add_index :table_name1, :referrer_token add_index :table_name2, :referrer_token

Add :referable to the devise line in your model:

class User < ActiveRecord::Base devise ..., :referable end

If you are using devise :all, you can add :referable to config.all in devise initializer: Devise.setup do |config| ... config.all = [..., :referable] ... end

== Model configuration

DeviseReferable adds a new configuration option, :referral_types. It should be an array of classes which can act as a referrer

== Routes

rails g devise_referable login

== Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

== Copyright

Copyright (c) 2010 Matt Van Horn, based on work by {Sergio Cambra}[http://github.com/scambra/devise_invitable]. See LICENSE for details.


Top Contributors

ilyakatz bolshakov