How to use rack middleware with Rails3?
问题 Hey guys, I'm trying to make the rack middleware NotFound to work with rails3 but I needed to make some changes to return some json, so I basically defined a new class : class NotFound def initialize(app, msg, content_type = "text/html") @app = app @content = msg @length = msg.size.to_s @content_type = content_type end def call(env) [404, {'Content-Type' => @content_type, 'Content-Length' => @length}, @content] end end I added this class above to "app/middleware/not_found.rb" and add this