Showing posts with label request url. Show all posts
Showing posts with label request url. Show all posts

Wednesday, June 23, 2010

Ruby on Rails: Request Url

<%= request.request_uri %> / <%= request.path%>
- display current url without base url
eg: /goldberg/auth/login

<%= request.referer %>
- display previous url with base url
eg: http://www.yoursite.com/goldberg/auth/login

<%= request.env['HTTP_HOST']%>
- display base url
eg: www.yoursite.com

<%= request.env['SERVER_PROTOCOL']%>
- display protocol
eg: HTTP/1.1

<%= request.url%>
- full url
eg: http://www.yoursite.com/goldberg/auth/login

<%= request.query_parameters.size %>
- display how many parameters found in current url
url eg: www.yoursite.com/index.html?key=3&d=4
answer: 2 => (2 parameters)

<%= request.path_parameters['controller'] %>
- display controller name from current url
eg: goldberg/auth

<%= request.path_parameters['action'] %>
- display action name from current url
eg: login

<%= request.inspect%>
- It will tell you everything thats inside request.(Long request)



If you find this useful, would you like to buy me a drink? No matter more or less, it will be an encouragement for me to go further. Thanks in advance!! =)