I did a quick search, but couldn’t find a direct answer. New to Rails and just trying to understand why this is the case. I’d really appreciate it if someone could just point of the piece of code that shows where it points to index.html if it exists, or, if that’s the wrong way of thinking about it, what the right answer is.
Share
In Rails 3, railties defines a default middleware stack (railties/lib/rails/application.rb) that lets each type of middleware access the request call. The first module in the stack is ActionDispatch::Static (it can be disabled with config.serve_static_assets). The static middleware module is in ActionPack (actionpack/lib/action_dispatch/middleware/static.rb). The relevant lines from that are:
@file_server is defined above as a Rack::File which is in rack/lib/rack/file.rb. It just reads the file and serves the contents as the body.
So when you delete index.html, the file_exist? call fails which just passes the request on to the next middleware and eventually will hit the normal Rails router.