问题
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