Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7884265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:45:10+00:00 2026-06-03T04:45:10+00:00

Found this gem Rack After Reply that says: A hook for Rack apps which

  • 0

Found this gem Rack After Reply that says:

A hook for Rack apps which fires after the response has been sent, and the socket to the client has been closed.
This is the ideal time to perform delayable, non-backgroundable tasks, such as garbage collection, stats gathering, flushing logs, etc. without affecting response times at all.

Usage

Simply add your callbacks to env['rack_after_reply.callbacks'].

use Rack::ContentLength
use Rack::ContentType, 'text/plain'
run lambda { |env|
  env['rack_after_reply.callbacks'] << lambda { ... }
  [200, {}, ['hi']]
}

But I couldn’t fit it into the Rails3 app.

Can anyone say on how to use this with a Rails3 app?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T04:45:11+00:00Added an answer on June 3, 2026 at 4:45 am

    You need to add the callbacks to the Rack env during the actual request, i.e. in your controller.

    You can get at the Rack env with the request object.

    In your controller:

    def index #or whatever your method is, you could do this in filter
      #normal controller code...
    
      request.env['rack_after_reply.callbacks'] << lambda do
        $stderr.puts "Hello from callback"
      end
    end
    

    The callback will be run after any request that gets routed to this method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Found this question that explained a way to communicate between layers. However there is
I found this question that is discussing what I would like to do, but
I found this gem https://github.com/michaeledgar/hash_syntax I don't quite understand how I can use it
So, I recently found this little gem. http://support.microsoft.com/kb/323308 Essentially, IE doesn't haven't Cache-Control: no-cache
I'm attempting to gem install twitter-bootstrap-rails on my windows machine. This gem has a
I found this in Gemspec file of surveyor gem . What does the following
I just set up this gem and pushed to heroku ok. However, I found
I'm trying to create a gem that wraps d3.js, Source can be found at
Started to have an issue this afternoon with the delayed_job process, found that the
I found this little gem in our codebase at work recently. I have to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.