module Middleware class Timestamp def initialize(app) @app = app end def call(env) env[:timestamp] = Time.now @app.call(env) end end end
并将其添加到application.rb(config.middleware.use)中