Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8916477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:15:08+00:00 2026-06-15T05:15:08+00:00

This may be a strange question, but it has come up in a project

  • 0

This may be a strange question, but it has come up in a project that I’ve been working on recently.

I have a Devise model called Student with a unique :sid parameter. The Student table in the database is already filled with Student objects with only :sid values set. I need to enable students to register using their :sid, setting the other attributes of the Student object and doing any Devise setup that is necessary.

How in the world should I set the registration up? Right now, I’m using a custom Devise RegistrationController with the following code:

# inside controllers/students/registration_controller.rb
def create
    if Student.exists?(:sid => params[:student][:sid].to_i)
        @student = Student.find_by_sid(params[:student][:sid].to_i)
        @student.update_attributes(params[:student])
        if @student.save
            set_flash_message :notice, :signed_up if is_navigational_format?
            sign_in(Student, @student)
        else
            set_flash_message :notice, :sign_up_failed
            redirect_to student_registration_path
        end
    else
        set_flash_message :error, :sid_not_found
        redirect_to new_student_registration_path
    end
end

This code merely updates the existing Student object.

I don’t know if it makes more sense to store a list of valid :sids somewhere else, or if I should do something else entirely to make this work.

EDIT:
As for my main question, I’m wondering whether this is the best way to go about only allowing registrations from a pool of existing user objects that are selected using an arbitrary value.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:15:09+00:00Added an answer on June 15, 2026 at 5:15 am

    If I understand your question right: you want to enable only those who have a certain token to register on the site and fill in their info. If this what you want to do then you could accomplish this by generating a token value (say 6 characters: 18ui7p) and store these in a separate table then if you want some one to register you send them a url that contains a valid token say

    http://example.com/users/sign_up?token=18ui7p
    

    and in your registrations controller you override new method to allow only a user that has a valid token (that you have generated and stored before in the db) to register as a user, the same in the create action, also don’t forget to remove/mark the token after it is used.

    This way if someone (say school admin) wants to add someone new in the system, they can generate a token and send it to the student in an email, which means you will provide an action that generates a token and send it to an email, of course this is accessible only by the admin.

    I just found a gem called devise_invitable which could do what you want, but you could just implement the solution yourself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may be kind of a strange question, but maybe somebody has an idea...
I know this may seem like a strange question, but say I have two
This may be a stupid question but I have a code with the following
This may sound like a very generic question but here it goes. I have
this may seem like a overly complicated question, but it has me driving me
This may be a strange question, but do 'try-catch' blocks add any more to
I have somewhat of a strange question that is not really technical, but I
This may sound like a strange question, but i need to redirect all .rar
This may sound like a strange question, but hopefully there is an answer out
Hi Guys this may seam a bit of a strange question but here goes:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.