Why would I delete the index.html file in the rails application to display the controller for the root directory?

I did a quick search but could not find a direct answer. New to Rails and just trying to understand why this is so. I would really appreciate it if someone could just point out a code snippet that shows where it points to index.html if it exists, or if this is the wrong way to think about it, the correct answer.

+3
source share
4 answers

In Rails 3, railties defines a default middleware stack (railties / lib / rails / application.rb) that allows each type of middleware to access a request call. The first module on the stack is ActionDispatch :: Static (you can disable it using config.serve_static_assets). The static middleware module is in ActionPack (actionpack / lib / action_dispatch / middleware / static.rb). Matching lines:

path   = env['PATH_INFO'].chomp('/')
...
if file_exist?(path)
  return @file_server.call(env)

@file_server is defined above as a Rack :: File, which is located in the /lib/rack/file.rb rack. It simply reads the file and serves the contents as a body.

So, when do you delete index.html, file_exist? a call that simply passes the request to the next middleware and eventually ends up in a regular Rails router.

+4

/ FIRST -. - rb. .

+2

Rails /public/index.html, , . , , , , rm public/index.html rails.

0

: " , , index.html, "

, - Rails, . Rails , html .. -.

Rails, , , - Rails , () . Rails, " " ( 404)... Rails URL- .

0

Source: https://habr.com/ru/post/1782174/


All Articles