I want to render a partial if my path is on a specific resource, but I don’t want to indicate the ID of the resource.
I want to load meta data tags held in a partial between my <head> tags if the path is on any video resource:
<head>
<%= render 'layouts/partial_name' if request.fullpath == video_path(params[:id]) %>
</head>
This only works, though, if I’ve requested a video resource, e.g., '/videos/92'.
You could try
request.full_path.starts_with? videos_path, orrequest.full_path =~ /^\/video/.However, there’s a better way to do this. In your layout:
In the view where you want to add meta tags:
This usage is the canonical example for the
content_formethod.