2013-11-24 56 views
1

url是mysite.com/lists/student其中lists是在重定向到rails應用程序的子域上安裝的rails應用程序。這些導軌2路線應該如何在導軌3中看起來像?

軌道2:

map.connect ':controller/:action/:id' 
    map.connect ':controller/:action/:id.:format' 
    map.connect "student", :controller => 'student', :action => 'index' 

鋼軌3我已經試過這些:

match "/student/" => "student#index" 
match 'student/:id', :to => 'student#index' 
match ':controller(/:action(/:id))(.:format); 

,但不工作。

「耙路」沒有輸出。

+1

「'rake routes' does not output」你的意思是沒有輸出嗎?在這種情況下,您可能沒有正確遷移您的項目。看看這篇文章:http://x-aeon.com/wp/2012/12/19/migrating-big-applications-from-rails-2-to-rails-3/ – Miotsu

+0

無論如何,「匹配」學生「=>」students#index「'應該可以工作。 – Miotsu

+0

我很喜歡使用rails_upgrade插件來簡化遷移,但我在共享主機解決方案中,並且認爲我沒有權限更改ruby版本,因此無法從1.9.3切換回1.8。我更新了.bashrc和.bash_profile指向1.8,但ruby版本停留在1.9.3。 –

回答

1

如果您打算使用match,則必須指定正在使用哪個HTTP謂詞。有關更多詳細信息,請參閱the routing documentation about this subject。一個簡單的例子是:

match '/student', to: 'student#index', via: :index 

我建議改變你的路線是基於上面的Rails路由指南。例如,假設這些是get請求:

get '/student', to: 'student#index' 
get 'student/:id', to: 'student#show' 
get ':controller(/:action(/:id))'