Rails: call another controller action from a controller

后端 未结 9 1051
眼角桃花
眼角桃花 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条回答
  •  爱一瞬间的悲伤
    2020-11-27 12:12

    Perhaps the logic could be extracted into a helper? helpers are available to all classes and don't transfer control. You could check within it, perhaps for controller name, to see how it was called.

提交回复
热议问题