Devise Invitable: Return a list of invitation tokens

301 Views Asked by At

I'm trying to add a button to my page that exports a list of the invited users with Devise Invitable. I want to include the invitation_tokens in that list. User.where.not(invitation_token: nil) works to return the list of users, but it doesn't show the invitation_token there. User.last.invitation_token does return the invitation_token for that specific user, so I know the information is accessible.

Rather than looping through each invited user to retrieve its invitation_token, is there a way to get ActiveRecord to automatically return the token with a user? For example, User.where.not(invitation_token: nil) currently returns the following:

#<ActiveRecord::Relation [#<User id: 6, email: "[email protected]", created_at: "2022-05-09 11:37:07", updated_at: "2022-05-09 11:37:07"]>

1

There are 1 best solutions below

0
anotheruser On

It looks like there's a security measure in Devise that prevents sensitive information form being shown. Workarounds can be found here: Rails & Devise: devise specific columns not showing up in rails console