I have the following
Rack::Attack.throttle('req/preview', limit: 3, period: 1.minute) do |req|
puts "Rack::Attack> #{req.params.inspect}"
req.params['item_id'] if "preview".in?(req.path) && req.post?
end
In my controller I have:
def preview
puts "Preview> #{params.inspect}"
...
end
When I run the following in my specs:
post items_preview_path(:item_id => @item.id, :preview_email => "test@test.com")
Here the print in the terminal:
Rack::Attack> {"preview_email"=>"test@test.com"}
Preview> {"preview_email"=>"test@test.com", "action"=>"preview", "controller"=>"items", "item_id"=>"1"}
I cannot figure out why I don't have access to params[:item_id] in the throttle block.
I have the following
In my controller I have:
When I run the following in my specs:
Here the print in the terminal:
I cannot figure out why I don't have access to params[:item_id] in the throttle block.