-2

I am using devise gem, I used :confirmable to let the user confirm his account so the email will be sent to to him after he signed up and if he open the link it will be confirmed immediately.. What I want is to send the email to the user, after he signed up to show him his account then to give him option to confirm or not. Something like radio button

Here is my code in the user model

  devise :database_authenticatable, :registerable,
     :recoverable, :rememberable, :trackable, :validatable, :confirmable



 before_create :confirm_email

  def confirm_email
    UserMailer.registration_confirmation(self).deliver
  end

in the mailier

default :from => 'info@eccsbc.com'

  def registration_confirmation(user)
    @user = user
    mail :to => 'nour@khatib.ca' ,:subject =>"New member please confirm"
  end

in the user_mailier tempalate

<%= link_to 'Confirm my account', confirmation_url(@user, :confirmation_token => @user.confirmation_token) %>
Blackcoat77
  • 1,574
  • 1
  • 21
  • 31
nourza
  • 2,215
  • 2
  • 16
  • 42
  • I understand your question, but what's the use case here? Why would you offer this choice? Either enable confirmation or don't. – Ariejan Oct 13 '16 at 08:55
  • I want to send this email to the admin so he can confirm the user not for the user. Something else not sure why all the emails confirms do I miss anything? – nourza Oct 14 '16 at 00:55

1 Answers1

0

So the easiest solution instead of having a radio button would simply be to do

<p>Would you like to confirm your account?</p> 

<%= link_to 'Yes', confirmation_url(@user, :confirmation_token => @user.confirmation_token) %>

<%= link_to 'No', root_path %> 
angkiki
  • 510
  • 5
  • 20
  • Can you explain more.. Where should I put these two options? – nourza Oct 13 '16 at 05:35
  • In your sign up form. Confirmable can only be decided at the moment of registration and not after in the email like you said. So a user will decide if he wants to go through the confirmation process during the sign up stage – angkiki Oct 13 '16 at 05:45
  • Where exactly in the sign up form? – nourza Oct 13 '16 at 05:52
  • Wait i'll just like to clarify. You want all users to be confirmable. You just want the users to have a choice to confirm their accounts in the email? What happens if they click no then? – angkiki Oct 13 '16 at 06:00
  • They will not be members on the website if they reject. I know it make no sense but I need it for a reason – nourza Oct 13 '16 at 06:04
  • I amended my answer with a simple solution. Hope its good enough. – angkiki Oct 13 '16 at 06:08