About Claudio

After graduating in Computer Science has contributed to develop complex web applications based on Java/J2EE and desktop applications with the. NET framework for the Ministry of Justice and ultimately for the banking ambit.

The passion for web in recent years has led him to be interested in more modern frameworks such as Ruby on Rails and Django, and to a development approach based on agile methodologies such as eXtreme Programming and SCRUM.

Claudio, I’ve been working on this for about two weeks and I’m just stuck. Everything I have looks exactly like you have showed except my model is called ‘user’. I’m getting a `no route matches ‘confirm_account’` message. I tried to change ‘put’ to ‘match’ in my routes.rb, but that threw a lot more errors (at least it was finding it, though…maybe?)

I appreciate you taking the time to write this up. It is very close to what I need for my site and it is helping me tremendously. I followed your instruction and I ran into an error. (I am sure I just did something wrong but I was hoping you might be able to help if you have time). It works all the way up to the entering the password part. Once I submit the password it gives and error.

I was looking to implement something similar when I ran across this post. I was considering using the built-in token_authenticatable module in Devise to provide access to a newly created account where the user has not set a password. I was going to set the password to something random and force a change when the user confirms the account. I was going to allow access to confirmation and password changing via the token_authentication. I am glad I ran across this because I don’t think I need to use the token_authenticatable module, I can just use the confirmation token! I think I will still just set the password to something random for a non-confirmed user since I don’t want to override the password validation methods in Devise as I have other models that need it.

Very subtle difference, but now any Devise resource can use this controller. (I added the check for present? in case someone tries to submit the form a second time.) Oh — you also have to change the routing configuration (which note that the new version of Devise now deprecates passing a block to #device_for:

Thanks again, Claudio — and if you have time, ha ha, please change above your Account.find to Account.find_by_confirmation_token above. Just in case someone is too lazy and they don’t read these comments. Again, thanks for documenting this sweet feature!

Also, thanks to Shane, I made my model methods and grammatized the error messages:

Serves me right for posting late at night! It worked for my clients model but devise gets confused with the same routing information for multiple resources. So here’s what works with multiple Devise resources:

Me again, but with sleep I noticed that if the user changes their email address then they are sent a confirmation email and, after clicking the confirmation link, the user is presented with the same confirmation screen asking them to enter in their new password. Whoops. The client is not expecting this behavior so here is how I modified my controller code: