Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between request.env['REQUEST_URI'] and request.env['REQUEST_PATH']?

What's the difference between request.env['REQUEST_URI'] and request.env['REQUEST_PATH'] in Rails? They always seem to contain the same value.

like image 871
Tom Lehman Avatar asked Oct 03 '09 23:10

Tom Lehman


1 Answers

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.

like image 193
Peter Wagenet Avatar answered Oct 14 '22 11:10

Peter Wagenet