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 8454815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:07:32+00:00 2026-06-10T12:07:32+00:00

i am working on rails3 application. In my application when a user registered first

  • 0

i am working on rails3 application. In my application when a user registered first time, an email has been sent to user with a verification link, after clicking that link i update the status_id and redirect user to login page. Here is my code :

code for token generation:

require 'digest/sha2'
class Subscription < ActiveRecord::Base


  validate :ids_must_be_present, :on => :create 

 def ids_must_be_present
    if status_id==0 
      generate_token
    else
      errors.add('Something gone wrong')
    end
  end

  def generate_token
    self.token = encrypt_string(id, generate_salt)
  end

  def encrypt_string(id, salt)
    Digest::SHA2.hexdigest(id.to_s + "prftnxt" + salt)
  end



  private

  def generate_salt
    self.object_id.to_s + rand.to_s + company_id.to_s  + Time.now.to_i.to_s
  end
end  

code to send email with link:

def email_verify
   if subscription = Subscription.find_by_id_and_token(params[:id], params[:token])
      subscription.update_attribute(:status_id, 1)
      redirect_to("/login/index", :notice => "Thanks, email successfully verified")
   else
     flash.now[:notice] = "Your email has not verified yet. Please verify your email by clicking the link we have sent you."
   end
  end

Email template with verification link:

Hello <b><%= @user.username %></b>,
<br/>
<br/>
Thank you for signing up .
<b> Please Verify your email</b>

    <%= link_to "verify", "http://localhost:3000/login/email_verify?token=#{@subscription.token}&id=#{@subscription.id}"%>

</br></br>
</br>

Now everything is fine, now my client want if user did not get verification email, then we some where give the option or link to request to resend verification mail.

i am thinking on to display flash msg on login attempt with a link to request for email.
but i am confused how do i do this any example or help would be helpful thanks.

  • 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-10T12:07:34+00:00Added an answer on June 10, 2026 at 12:07 pm

    Hi friends i got a solution, i have used a method in login controller that check the email is verified or not and if not verified a flash message displayed. The message contains the link .
    When a user click on that link i resend the verification mail.
    Here is my code:

    subscription = Subscription.find_by_company_id_and_plan_id(current_company.id, current_company.plan.id)
          link = "<a href= '/login/resend_verification_email'>Click</a>"
          if subscription.status_id == 0
             flash[:error] = "Your email is not verified. Please verify before login. <br/> #{link} here to resend verification email.".html_safe 
             redirect_to :back
          end
    

    and in login controller:

    def resend_verification_email
        subscription = Subscription.find_by_company_id_and_plan_id(current_company.id, current_company.plan.id)
        Email.verify_email(current_user, subscription).deliver
        redirect_to :back
        flash[:success] = 'Verification email has been resend successfully, please check your inbox.' 
      end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a Rails application that has user authentication which provides an
I've just got a jquery function working with my rails3 application. When a user
I am working in a Rails application. The app has concepts like user can
The Rails application I'm working on, has two central pieces: users and groups. A
I am currently working on rails3 application that uses jQuery. I have a javascript
I'm working on a Rails 3 application that uses devise for user authentication. I
I installed the active_admin gem in a working rails application. After doing this, the
I have been working with rails3 and have been trying to create a simple
I'm working on a rails application that will migrate user content. I need to
Rails 3.2.2 has been working fine in both my development environment, and on my

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.