Open scarroll32 opened 4 years ago
Similar for me:
NoMethodError (undefined method `keys' for #<ActiveSupport::Cache::DalliStore:0x00007ffbfad7e3f0>)
I installed redis-rails
gem, and configured the Rails cache store to :redis_store
, and I went past it into the next problem:
NoMethodError (undefined method `without' for #<Hash:0x00007ff2776a4bb0>
Did you mean? with_options):
rack_attack_admin (0.1.2) app/controllers/rack_attack_admin/rack_attack_controller.rb:9:in `index'
Relevant code:
@counters_h = Rack::Attack.counters_h.
without(*Rack::Attack::BannedIps.keys)
render
Not sure where without
method comes from but it's definitely not part of Ruby Hash.
Here's two monkey-patches to move forward:
require 'rack_attack_admin'
module RackAttackAdmin
class RackAttackController < RackAttackAdmin::ApplicationController
# Web version of lib/tasks/rack_attack_admin_tasks.rake
def index
@default_banned_ip = Rack::Attack::BannedIp.new(bantime: '60 m')
@counters_h = Rack::Attack.counters_h.with_indifferent_access.except(*Rack::Attack::BannedIps.keys)
render
end
end
end
module RackAttackAdmin
class ApplicationController < ::ApplicationController
helper_method \
def is_redis?
Rack::Attack.cache.store.to_s.match?(/Redis/)
end
end
end
This is all that's needed to get it working, as long as Redis Cache Store from https://github.com/redis-store/redis-rails is used. Memcached is not an option, it does not have an option to list all keys.
For Rails 4.2 specific monkey patches, see #2.
Doesn't seem to work ...