update Middleware for rails 4.1