Search code examples
ruby-on-railsdevise

How to set password length differently for development and production in devise


I have a rails password like so in my devise.rb:

  config.password_length = 8..128

I would like to set this to

if development?
  config.password_length = 1..128 
else
  config.password_length = 8..128
end

But this gives me this error: NoMethodError: undefined methoddevelopment?' for main:Object`


Solution

  • I believe you want something more like:

    if Rails.env.development?
      config.password_length = 1..128 
    else
      config.password_length = 8..128
    end