Make sure middleware is inserted when config.threadsafe! is enabled in rails