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

后端 未结 6 1794
北荒
北荒 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:15

    If you came from the photo_album page, you should be able to do:

    redirect_to :back
    

    Otherwise, you should be able to do a named route like:

    redirect_to photo_album_path(photo.album_id) # or whatever the association key is
    

    BTW, why do you have photo_albums mapping to photo_galleries? It's a lot less confusing if you named your resources and routes in a similiar manner. ie: if you wanted your route endpoints to use /photo_galleries you should name your resource PhotoGallery.

提交回复
热议问题