What’s the difference between request.env[‘REQUEST_URI’] and request.env[‘REQUEST_PATH’] in Rails? They always seem to contain the same value.
What’s the difference between request.env[‘REQUEST_URI’] and request.env[‘REQUEST_PATH’] in Rails? They always seem to contain
Share
I believe delroth is correct about the distinction, however in almost all cases it’s better to use the methods in Request instead of directly accessing the environment variables.
request.request_uri returns the requested url including the query string and without the domain.
request.path returns the path of the request without the query string, domain and any relative root (if your app runs from a directory other than root).
See the Rails API for ActionDispatch::Request to see other helpful methods.