rubyvoltrb

Error: "uninitialized constant Object::Rack" when using gem rack-throttle in ruby Volt framework


I am trying to throttle malicious from my website by using rack-throttle in the new Volt framework. Here is my code in the compnent/config/initializers/boot.rb file:

Volt.current_app.middleware.use(Rack::Throttle::Minute, max: 60)

Limiting the requests per minute works correctly, but I am getting an error message that says the following:

Uncaught NameError: uninitialized constant Object::Rack

Any help would be much appreciated.


Solution

  • Did you require 'rack/throttle' first?

    Also, for middleware, you want to be sure its only running on the server:

    unless RUBY_PLATFORM == 'opal'
      Volt.current_app.middleware.use(Rack::Throttle::Minute, max: 60)
    end