3 is the id in the database, but it is not necessarily always going to be 3. You have to get the ID of the identity provider from the Database. I used memoization for this case in ability.rb. If you know of a better solution, I'd love to hear it.