How to redirect to previous page from multiple places?

狂风中的少年 提交于 2019-12-12 18:42:48

问题


I'm likely missing something really simple here...

Say I have model called Option. I then list these options in the view, with Enable / Disable buttons that lead to a controller action which then enables or disables that particular Option.

If the list is only in one place, I know just to call redirect_to or render to have the user go back to correct page, since there's only one.

What if the same list is in multiple places?

Meaning, if there's only one controller with enable / disable actions, how do I make that controller "return" the user to the page where they clicked the button?

I thought about keeping the previous page in a session variable or something but that seems wrong.


回答1:


you can use redirect_to :back or request.env['HTTP_REFERER']



来源:https://stackoverflow.com/questions/14685510/how-to-redirect-to-previous-page-from-multiple-places

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!