Simple invitation access code using Rails 4 & Devise

Want a user to provide a simple access/invitation code to register for an account using Rails 4 and devise?

See my github gist below. Supports having one dumb access code, nothing fancy. But, worth sharing: it’s not immediately straight forward how to do this.

This is achieved by:

– Setting up a virtual attribute on the user model called invitation_code

– Telling Rails strong parameters to allow invitation_code as an attribute on user when signing up

– Adds form field for invitation_code on the registration page

4 responses to “Simple invitation access code using Rails 4 & Devise”

  1. RIch says:

    Hi Steve,

    Trying to implement this but running into the error message alot

    “Invite code invalid. Ask Steve or try again.”

    Rich

  2. Rich says:

    Hi Steve,

    I’m having a little trouble with this still, it works locally but not in production…?

    Any help would be appreciate

    Rich

  3. Rick Denman says:

    my devise install does not have (or at least I can’t find it) an app/controllers/users folder. How can I find that registrations_controller.rb file?

  4. Daniel Trostli says:

    Lol. Was just googling how to solve this. Funny to see you wrote about this Steve. Hope you are well!!

Leave a Reply

Your email address will not be published. Required fields are marked *