如何在设计中为开发和生产设置不同的密码长度

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

我的 devise.rb 中有一个 rails 密码:

  config.password_length = 8..128

我想将其设置为

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

但这给了我这个错误: NoMethodError: undefined method发展? main:Object`

我相信你想要的更像是:

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