0

What is the best practice with Devise 2.1 to build a simple invite system just like Pinterest?

In other words, I would like to allow new users to sign-up with an invitation form. Then, I would like that:

  1. First, Devise send a "Thanks for Joining the Fuu Waiting List" email.
  2. To finish, maybe with a cron-task every 3 hours, Devise send a "You've Been Invited to Join Fuu" email.

I'm using Devise 2.1 with confirmable module. I think devise_invitable gem is not useful in my case, because invited user should not be able to invite new user.

T5i
  • 1,470
  • 1
  • 18
  • 34

2 Answers2

0

I asked a kindoff similar question before maybe it is of any use to you:

rails beta request signup with social media sharing reward

Basically what you want to do is store the email of the user in a "requests" model so you get a table where you can store the email and create a field type boolean with processed. This results in:

|email         |processed|
john@doe.com    true
alex@google.com false

Then in /lib/tasks/ create a new rake tasks that loops true all your requests and process them in batches. This is the rough Idea but it should get you started.

Community
  • 1
  • 1
Rubytastic
  • 15,001
  • 18
  • 87
  • 175
  • I see... But I mean, is there a clean way to do so? In my app, pending user (asking for an invit) are just like normal user, with a `confirmed_at` field to `nil`. If there's a clean howto step-by-step, it would be awesome. – T5i Jun 14 '12 at 13:15
0

Rough idea to get you started: What you basically want is store wich users are signed up true your invitation system. Stackoverflow is not for complete workouts its to get you in the right direction ;) this is to complex to totally write out.

Routes:

    get '/signup/:code' => "devise/registrations#new"

Controller:

params[:code]

unless params[:code] 
   .. check if the code is correct
   .. render your form here
else
  .. you need an invitation code to join our site
end

Model

on_create :set_processed
def set_processed
  .. set processed to true
end
Rubytastic
  • 15,001
  • 18
  • 87
  • 175