Beta registration with Devise

I recently included a Devise authentication system in a rail testing application. The test application simply contains the model of projects / controller / view that are behind authentication.

Now I am adding a beta invitation system so that only users who have received an invitation from another user can join the site. I implemented this system as follows: http://railscasts.com/episodes/124-beta-invitations .

The only problem I am facing is that the beta invitation requires me to add logic to the user controller, which you cannot do through Devise. I am trying to create a new registration controller using Users :: RegistrationsController <Devise :: RegistrationsController, which will basically be the same as the Devise controller, but will allow me to add additional logic to the beta invitation system.

However, I cannot get this new controller to work (and I am also having problems with what I should include in this new controller). I added the following to the routes file:

resources: registration

resources: invitations

resources: projects

devise_for: users

devise_scope: user do
get 'users / sign_up /: invite_token' => "Register # new"
end

What should I add to this new registration controller to simulate the functionality of the original development / registration controller?

+8
ruby-on-rails devise ruby-on-rails-plugins
source share
1 answer

In your user model, add a confirmation in which you verify that the user's email is on the beta invitation list.

This SO is very similar: Whitelisting using ... I added the same code there, which here matters:

class User < ActiveRecord::Base devise :database_authenticatable, :registerable #etc before_validation :beta_invited? def beta_invited? unless BetaInvite.exists?(:email=>email) errors.add :email, "is not on our beta list" end end end 
+10
source share

All Articles