Rails:从控制器调用另一个控制器操作 [英] Rails: call another controller action from a controller
本文介绍了Rails:从控制器调用另一个控制器操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要从控制器 B 调用控制器 A 中的创建操作.
I need to call the create action in controller A, from controller B.
原因是当我从控制器 B 调用时需要不同的重定向.
The reason is that I need to redirect differently when I'm calling from controller B.
可以在 Rails 中完成吗?
Can it be done in Rails?
推荐答案
您可以使用重定向到该操作:
You can use a redirect to that action :
redirect_to your_controller_action_url
更多信息:Rails 指南
只渲染新动作:
redirect_to your_controller_action_url and return
这篇关于Rails:从控制器调用另一个控制器操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文