Take the 2-minute tour ×

I would like to add a invite code requirement for users to register in my application. I investigated the devise_invitable gem for devise and this looks very promising. However, It should not be possible to continuously invite people to the application, like devise_invitable does.

To solve the problem, I need to implant user levels in my application. I found this project on github and now I got the following idea: Once a user registers (invited by another existing user) it starts in level 1 and must complete tasks in order to archive experience points. He works his/her way up to the next level where he can invite 1 new member and then in the next level he can invite 1 other and in the next level, the user can invite 2 members, so on, so on.

I am fairy new to Ruby and I'd like to know how to encomplish this and to know if this is even possible to insert in my users controller.

Thank you for reading and have a nice day.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

This should be a fairly straight forward process, as the number of invitations a user has is just an integer stored in your database. It could be something as simple as:

def level_up(level)
  self.invitation_limit += level

While a very simple implementation, you just pass in the users level, add it to their current number of invitations, and save the user. It all really depends on how fancy you want to get, but it really comes down to basic math, and saving it to the database.

share|improve this answer
Thank you for clearing it out. I did not seen it before but it is been pointed out in a fork 8 days ago. –  user1932402 Dec 29 '12 at 18:29

Your Answer

