This is an example project that demonstrates how to implement OTP two-factor authentication in devise so that the user is asked for their OTP code as a second login step.
A step by step guide is available here: Implementing OTP two-factor authentication as a second login step with Rails and Devise