Call accept_invitation_url in a different view

时间:2017-10-12 09:36:56

标签: ruby-on-rails devise

I need to call accept_invitation_url(@resource, :invitation_token => @token) in a different view outside of the devise mailer and when doing that i got an err

ActionView::Template::Error: Could not find a valid mapping for nil
from /var/lib/gems/2.3.0/gems/devise-4.3.0/lib/devise/mapping.rb:44:in `find_scope!'

Is it not the right way to do it? I just want to be able to invite users from a different view

1 个答案:

答案 0 :(得分:0)

我找到了一种方法来做到这一点。

@token, encrypted_token = Devise.token_generator.generate(User, :invitation_token) @user.update_attribute(invitation_token: encrypted_token)