Autotest keeps running

I had an issue with autotest where the tests would just keep running, even when all the tests passed. After doing some searching I found the following code helpful from this post:

Put this in your ~/.autotest, leave out the growl line if you’re not using that.

require 'autotest/growl'

Autotest.add_hook :initialize do |at|
  %w{.git vendor rerun.txt}.each {|exception| at.add_exception(exception)}

When I initially tried this code it didn’t work. To figure out why autotest thought it had to keep running I ran the following:

find ./ -cmin -1 

This will show you any files that changed in the last minute. I had to add db, log, system and public to the list above. Depending on your configuration you might run into other files or folders that need to be excluded.

Issue using insert_after/before “ActionDispatch::Static”

We are currently building a new product on Rails 3 with a couple custom middleware rack apps. Everything is working great on development and we’re progressing nicely. Today I decided to start setting up the production environment and the following error popped up:

No such middleware to insert after: "ActionDispatch::Static"

I had this in my config/application.rb:

config.middleware.insert_after('ActionDispatch::Static', '::API::Throttle')

I received this error while trying to run rake or startup unicorn. After looking around trying to figure out what I was doing wrong I discovered this in the production config.

config.serve_static_assets = false

Essentially what this does is remove “ActionDispatch::Static” from the rails middleware stack. I had no idea that I could not rely on that being there.

Solution, use insert_before ‘Rack::Lock’ instead:

config.middleware.insert_before('Rack::Lock', '::API::Throttle')

Hope this saves someone some time!