Devise: Remember Me Checked by Default

For ‘s login form, I want to make the ‘remember-me’ checkbox to be checked by default. Yeah I know, should be pretty easy.
But as a Lazy Programmer(tm), I immediately googled that and went to the first suitable stack overflow question.

And here is the answer, just modify the remember_me part of your devise login form like this

<%= f.check_box :remember_me, (resource.remember_me ? {} : { checked: true }) %>

The ternary check is there to prevent the case that if a user make a mistake setting their credential, the check box automatically checked on form reload even though they unchecked it before.

The SO link: