2012-04-24 69 views
1

我有这个在我耙路线:如何重定向到特定的控制器?

{:subdomain=>/m/, :action=>"destroy", :controller=>"mobile/home"} 
                   mobile_disclosures GET /disclosures(.:format)                          {:subdomain=>/m/, :action=>"index", :controller=>"mobile/disclosures"} 
                       POST /disclosures(.:format)                          {:subdomain=>/m/, :action=>"create", :controller=>"mobile/disclosures"} 
                  new_mobile_disclosure GET /disclosures/new(.:format)                         {:subdomain=>/m/, :action=>"new", :controller=>"mobile/disclosures"} 
                  edit_mobile_disclosure GET /disclosures/:id/edit(.:format)                       {:subdomain=>/m/, :action=>"edit", :controller=>"mobile/disclosures"} 
                   mobile_disclosure GET /disclosures/:id(.:format)                         {:subdomain=>/m/, :action=>"show", :controller=>"mobile/disclosures"} 
                       PUT /disclosures/:id(.:format)                         {:subdomain=>/m/, :action=>"update", :controller=>"mobile/disclosures"} 
                       DELETE /disclosures/:id(.:format) 

,我想我的控制器来重定向:通过尝试这样的事情mobile_disclosures

redirect_to :controller=>'mobile_disclosures', :action => 'show' 

但我得到的错误:

No route matches {:controller=>"mobile/mobile_disclosures", :action=>"show"}

任何ide我的语法出了什么问题,我哪里出错了?

回答

4

显示需要一个ID,因此您还需要传入ID。

redirect_to :controller=>'mobile_disclosures', :action => 'show', :id => some_id 
+0

是的,但即使做动作=> '索引' 给出了错误:没有路由匹配{:控制器=> “移动/ mobile_disclosures”} – GeekedOut 2012-04-24 18:02:17

+0

尝试做这样的事情:redirect_to的mobile_disclosure_url(SOME_ID) – Tam 2012-04-24 18:04:01

+0

顺便说一句,我应该是some_id - 我不认为我有一个身份证要通过。我认为重定向到索引控制器实际上是我应该做的。 – GeekedOut 2012-04-24 18:05:12