0.01
No commit activity in last 3 years
No release in over 3 years
It tracks the referring entity via cookie, and creates a record when user registers.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0

Runtime

~> 1.0.0
 Project Readme

devise_referable¶ ↑

It adds support to devise for tracking users that were sent by referrers modeled as other classes in your app.

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.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

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 © 2010 Matt Van Horn, based on work by Sergio Cambra. See LICENSE for details.