2009-07-03 36 views

回答

6

您需要在您的config/routes.rb文件中配置map.root路徑。

map.root :controller => "blogs" 

# This would recognize http://www.example.com/ as 
params = { :controller => 'blogs', :action => 'index' } 

# and provide these named routes 
root_url # => 'http://www.example.com/' 
root_path # => '' 

http://api.rubyonrails.org/classes/ActionController/Routing.html

+0

謝謝。因此,這需要index.html.erb頁面存在於與特定控制器關聯的視圖文件夾中 - 我必須將其從我當前的index.html文件所在的公共文件夾中移出。 – parlia 2009-07-03 20:47:02

2

公共/ index.html的是平面文件,並通過任何模板不進去(一切都在/公/就是這個樣子。)

如果你想在模板化您的索引頁,您需要通過控制器和視圖運行請求。您可以使用map.root將應用程序的根URL映射到控制器:

map.root :controller => 'home' 
0

現在答案已過時。假設index.html.erb文件在控制器下,並且視圖患者。 在軌道3,你會做這樣的:

match "/" => "patients#index" 
1

或者你可以做根:

的config/routes.rb中

root to: 'index.html.erb' 

一定要刪除index.html文件

相關問題