I'm using Devise and Devise-invitable. However when I try to accept an invitation, it says the token is invalid. There's an issue with the new devise on how it saves the token...which I know is causing the issue (https://github.com/scambra/devise_invitable/issues/402)
However, i'm not sure how to fix it still. The creator says use @token...but I have no idea how to get @token. Where does this variable come from? Here's what I have so far:
class Users::InvitationsController < Devise::InvitationsController
private
def invite_resource
resource_class.invite!(email: params['user']['email'], company_id: current_user.company.id) do |u|
# skip sending emails on invite
u.invited_by_id = current_user.id
u.invited_by_type = 'User'
u.skip_invitation = true
u.invitation_sent_at = Time.now
end
end
def accept_resource
debugger
resource = resource_class.accept_invitation!(update_resource_params)
end
and the link I'm using:
= link_to 'Accept invitation', accept_invitation_url('user', :invitation_token => @token)
previously instead of @token I am using invitation.invitation_token but I guess that's not a hashed version? How do I insert the correct version into the above acceptance link?
Your emails link looks fine as
@tokenis generated by the mailer. If you are like me you could have an invalid column type. For example, on mine invitation_created_at was the wrong type, so I did a migration to change it to datetime: