开发者

Rails routes - getting a directory listing instead of the "Hello, Rails!" page

I'm going through the Rails getting started tutorial and I'm having trouble with the routing part. I'm at the part right after they have you delete public/index.html and change config/routes.rb. When I visit my project in the browser, I get a di开发者_开发技巧rectory listing instead of the "Hello, Rails!" thing. If I bring back public/index.html, I see the "Welcome aboard" page again.

Here's my config/routes.rb minus comments:

Blog::Application.routes.draw do
  get "home/index"
  root :to => "home#index"
end

I've tried removing the get "home/index" line and that doesn't fix it.


Rails itself would never return a directory listing. Whatever you are using to run your Rails application is not configured correctly. More than likely you have configured it to point to the root of the Rails application rather than the public folder inside of it.

Hard to tell, given the lack of information in the question.


You need to tell Rails what to route home/index to.

Blog::Application.routes.draw do
  get "home/index" => "home#index"
  root :to => "home#index"
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜