开发者

rails - redirect back unless previous page was artist page

开发者 https://www.devze.com 2023-02-08 07:54 出处:网络
I\'d like to redirect b开发者_JS百科ack to the previous page, UNLESS the previous page was my \'artist\' controller\'s \'show\' action.

I'd like to redirect b开发者_JS百科ack 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? Then you can say something like:

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

精彩评论

暂无评论...
验证码 换一张
取 消