开发者

My routes.rb file doesn't redirect me to /

I have created a NEW rails application using

rails new rail_app

So if I want to see my development site I need to do the following

http://localhost:3000/Site/index

I want to reroute all requests to http://localhost:3000

The book I'm using to le开发者_如何学运维arn from is an older version of rails and it tells me to uncomment

map.connect '', :controller => 'site', :action => 'index'

but it doesn't seem to work. Any help would be appreciated.


You need to direct a controller action to root using the root command. See this guide:

http://guides.rubyonrails.org/routing.html#using-root


Delete the Index.html from public folder.

Create a new controller say home using

rails g controller home

Add a index.html to app/views/home.

Open routes.rb

uncomment root :to => "welcome#index"

rewrite it as root :to => "home#index"

Now if you type http://localhost:3000 , you will be redirected to your index page.

You can also go through http://guides.rubyonrails.org/routing.html for advanced routing concepts.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜