How do I redirect back to a page I'm currently on?

后端 未结 6 1802
北荒
北荒 2021-02-12 16:24

In my users photo album page they see photos they have uploaded and each photo has a \'make default\' link on it. When the user clicks make default, then the id of

6条回答
  •  遥遥无期
    2021-02-12 17:24

    In Rails 5 it was introduced the function:

    redirect_back(fallback_location: root_path)
    

    It does redirect back whenever the HTTP_REFERER is known. Otherwise it redirects to the fallback_location.

    The redirect_to :back is deprecated and will be removed from Rails 5.1.

提交回复
热议问题