Let's look at the source! Both variables come from the helper class Rack::Request . It provides a good interface for query parameters. Rack applications do not need to use Rails, but Rails uses it.
Variables for internal use Rack::Request . rack.request.form_vars contains the rack.request.form_vars POST body and rack.request.form_hash contains the parsed hash. ActionDispatch::Request inherits from Rack::Request and receives parameters using Rack::Request#POST , which reads the last variable. You can use Rack::Request yourself to change it.
class YourMiddleware def initialize(app) @app = app end def call(env) req = Rack::Request.new(env) req.POST["authenticity_token"] = "foo" end end
source share