I use devise_invitable (2.0.6)
invitation_accepted? returns FALSE in after_invitation_accepted CALLBACK but when I pause here and check in rails console it gives me true for invitation_accepted?
user.rb
after_invitation_accepted :create_something
def create_something
create_service unless invitation_sent_at? && !invitation_accepted?
end
here, invitation_accepted? is false inside this callback but, when I pause here and check in rails console it gives me true
Did I miss anything??
There is comment right above the
invitation_accepted?in the source code:That means
invitation_accepted?is nottruewhile the user is accepting the invitation, but only after the user accepted the invitation.When looking at what the implementation of
accept_invitation!then we see that@accepting_invitationis set totruein the method before the invitation is accepted, but it is not set tofalseafter the record in the database was updated.What means only after re-loading the user from the database
invitation_accepted?will returntrue.