如何重定向到特定的控制器?

时间:2012-04-24 17:57:49

标签: ruby-on-rails ruby

我在我的佣金路线中有这个:

{: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'

但是我收到了一个错误:

  

没有路线匹配{:controller =>“mobile / mobile_disclosures”,:action =>“show”}

知道我的语法有什么问题以及我哪里出错了?

1 个答案:

答案 0 :(得分:4)

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

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