In my Rails app, what would be the way to access a Devise config variable directly from a view?
I want to show config.allow_unconfirmed_access_for
from Devise's :confirmable
module. This variable is set in devise.rb
initializer:
Devise.setup do config.allow_unconfirmed_access_for = 3.days end
Thanks!
Devise is an excellent authentication system made for Rails that allows us to easily drop-in User functionality into our project. Devise only includes an email and password for registration, let's also add our own username to our User model. We also want to have a unique index on our username.
Our out-of-the box Devise setup is now working with Rails 7. Once again, if you'd like to refer to any of the code for this setup, or use the template wholesale for a new app, the code is available on GitHub, and you may also use it as a template repo to kick off your own Rails 7 devise projects.
The configurations on devise.rb
file are replicated on your Devise model, so if your Devise resource is User
, you should be able to access it through User.allow_unconfirmed_access_for
.
So, create an instance variable on your controller and assign this value to it, and then you'll be able to show it on your view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With