Rails: call another controller action from a controller

后端 未结 9 1063
眼角桃花
眼角桃花 2020-11-27 11:47

I need to call the create action in controller A, from controller B.

The reason is that I need to redirect differently when I\'m calling from controller B.

9条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-27 12:09

    You can use a redirect to that action :

    redirect_to your_controller_action_url
    

    More on : Rails Guide

    To just render the new action :

    redirect_to your_controller_action_url and return
    

提交回复
热议问题