I tried what was exposed in this (https://github.com/plataformatec/devise/wiki/How-To:-Override-confirmations-so-users-can-pick-their-own-passwords-as-part-of-confirmation-activation) wiki page using devise 3.5.2 and rails 4.2.1 in a rails engine, and was always getting 'Invalid token' when trying to confirm an account.
I don't know if the wiki should be updated or if there is some other issue.
When I replaced
@confirmable = User.find_or_initialize_with_error_by(:confirmation_token, confirmation_token)
with this:
@confirmable = User.find_or_initialize_with_error_by(:confirmation_token, original_token)
Everything worked as expected
The wiki is maintained by the community. So if there aren't any up to date instructions, we recommend you to explore the solution yourself and hopefully contribute your findings back!
In particular, given that you already found the proper solution, it would be awesome if you could just update the wiki. THank you!
I hit this problem too. The fix is counterintuitive. It's strange because it looks like you are taking the raw, unencrypted token from the params and looking up the user from that. But I thought only the encrypted token was stored with the user.
So is Devise doing something behind the scenes here with this line?
original_token = params[:confirmation_token]
Just update the wiki https://github.com/plataformatec/devise/wiki/How-To:-Override-confirmations-so-users-can-pick-their-own-passwords-as-part-of-confirmation-activation/_compare/030dda7c5edaf339b7c0023139fbd3214f702cad...c6a9649499dc8f73d77d2e4705bbeb1f1b334568