rails 6.0.3
How to branch the link destination to be displayed on the page according to the ** path name ** in ʻURL` of the page before the transition.
https:///www.example.com/user
If so, the pathname is / user
Applicable view file
<% if URI(request.referer.to_s).path == 'Path name' %>
#Link destination when the previous page is the specified path
<% else %>
#Other links
<% end %>
request.referer
returns a string.to_s
so that an error does not occur when a request is made with a numerical value (ʻinteger) in ʻURL
.request.referer
using Ruby
's ʻURI module``.How to get all URLs and branch the link to be displayed on the page https://qiita.com/taka_571/items/9b1c82d8fcc602df8a1a
Recommended Posts