Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ページ遷移で来たかどうか
- def page_transition?
- # !!! リダイレクトではリファラーは更新されないので、注意
- # URL直打ち
- return true if request.referer.nil?
- # ちゃんと遷移してきた
- current_path = request.path_parameters
- referer_path = Rails.application.routes.recognize_path(request.referer)
- current_path[:controller] != referer_path[:controller] || current_path[:action] != referer_path[:action]
- end
- # getパラメーターの保持
- def redirect_condition
- if page_transition?
- # セッションあり/他ページからの遷移 の場合は前回requestを以てredirectする
- # 他ページ遷移を確認しておかないとクリアが効かなくなる(paramsなし=クリアという仕様になっているため)
- redirect_to game_reports_path(session[:query_parameters]) if session[:query_parameters]
- # 残念ながら、他ページからの遷移で永久機関になってしまう。
- else
- session[:query_parameters] = request.query_parameters
- end
- end
Add Comment
Please, Sign In to add comment