"mobile/home"} -6ren">
gpt4 book ai didi

ruby-on-rails - 如何重定向到特定 Controller ?

转载 作者:太空宇宙 更新时间:2023-11-03 17:57:48 25 4
gpt4 key购买 nike

我的佣金 route 有这个:

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

我正在尝试将我的 Controller 重定向到:mobile_disclosures

通过尝试这样的事情:

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

但是我得到一个错误:

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

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

最佳答案

Show 需要一个 ID,因此您也需要传入该 ID。

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

关于ruby-on-rails - 如何重定向到特定 Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10303371/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com