简体   繁体   English

rails-重定向回,除非上一页是演出者页面

[英]rails - redirect back unless previous page was artist page

I'd like to redirect back to the previous page, UNLESS the previous page was my 'artist' controller's 'show' action. 我想重定向回上一页,除非上一页是我的“艺术家”控制器的“表演”动作。

So I guess it would look something like: 所以我想它看起来像:

if *previous page was artist show*
  redirect_to [track.artist, track]
else
  redirect_to :back
end

My question is - how do I test if the previous page was my artist controller's show action..? 我的问题是-如何测试上一页是否是我的艺术家控制器的表演动作。

Perhaps request.referer is what you're looking for? 也许request.referer是您要找的东西? Then you can say something like: 然后,您可以说类似:

if request.referer == artist_url(track.artist)
  redirect_to [track.artist, track]
else
  redirect_to :back
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM