小编Ked*_*tna的帖子

设计可锁定 - 如何使用 unlock_in 解锁帐户

让我先发布我所做的:

config.lock_strategy = :failed_attempt
config.unlock_keys = [ :email ]
config.unlock_strategy = :both
config.maximum_attempts = 10
config.unlock_in = 30.minutes
Run Code Online (Sandbox Code Playgroud)

我已经添加了相应表中的所有字段,并添加了:也可以在模型中锁定。

我面临的问题是,我的帐户在 10 次错误尝试后被锁定,而管理员能够登录并手动解锁它。

然而,我的第二种情况是,我需要在 30 分钟后按照我指定的方式解锁帐户。

我需要知道我是否应该调用任何单独的方法来让 unlock_in 工作。

ruby-on-rails

9
推荐指数
2
解决办法
3925
查看次数

Ruby - 转换多个数组以生成哈希

我正在尝试将3个不同的数组转换为单个Hash.

这是3个阵列

@vehicle_numbers = ["Registration Number 1", "Registration Number 2", "Registration Number 1"]
@vehicle_colors = ["red", "blue", "green"]
@allocated = [true, true, true]
Run Code Online (Sandbox Code Playgroud)

我想要实现的是

{1=> ["Registration Number 1", "red", true], 2=> ["Registration Number 2", "blue", true]}
Run Code Online (Sandbox Code Playgroud)

到目前为止,我已经实现了这一点

{1=> ["Registration Number 1", "red"], 2=>["Registration Number 2", "red"]}
Run Code Online (Sandbox Code Playgroud)

我正在尝试将已分配的密钥添加到现有哈希中,但我无法弄清楚,它有什么问题.

@lines.each do |line|
      @method_name = line.split[0]
      if @method_name == "park"
        @vehicle_numbers << @vehicle_number = line.split[1]
        @vehicle_colors << @vehicle_color = line.split[2]
        @vehicle_info["#{@vehicle_number}"] = @vehicle_color
        # puts @vehicle_info["#{@vehicle_number}"] = @vehicle_color
      end
    end
    @slots = 1.step(@vehicle_numbers.count, …
Run Code Online (Sandbox Code Playgroud)

ruby arrays hash

3
推荐指数
1
解决办法
93
查看次数

标签 统计

arrays ×1

hash ×1

ruby ×1

ruby-on-rails ×1