Ruby-on-rails 将一个控制器重定向到另一个控制器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11282846/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 03:37:03  来源:igfitidea点击:

Redirect One Controller to another Controller

ruby-on-railsrubyruby-on-rails-3ruby-on-rails-3.1

提问by Adnan

I have two controllers users & movies. All, I want to do, redirect from user#something to movie#something. is it possible??

我有两个控制器用户和电影。所有,我想做的,从用户#something 重定向到电影#something。是否可以??

回答by Peter Piper

redirect_to :controller => 'controllername', :action => 'actionname' 

where controllername is the name of your controller and actionname is the name of your action. this works for rails 4 but should also work for older versions of rails

其中 controllername 是您的控制器的名称,actionname 是您的操作的名称。这适用于 rails 4,但也适用于旧版本的 rails