The only problem i...">

Rails how to request url except URL parameters?

I create this link tag:

<link rel="canonical" href="<%= request.url %>" /> 

The only problem is that this is a complete url with parameters.

How can I request a url without any parameters?

+7
source share
2 answers

request.url.split('?').first

+19
source

request is ActionDispatch :: Request and subclasses of Rack :: Request. Rack :: Request has a path method that might interest you:

 <%= request.path %> 

If your request.url is http://example.com/where/is?pancakes=house%3F , then request.path should be /where/is .

+10
source

All Articles