浙江省高等学校教师教育理论培训

微信搜索“毛凌志岗前心得”小程序

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

WEDNESDAY, JUNE 23

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)

posted on 2010-11-15 19:14  lexus  阅读(440)  评论(0编辑  收藏  举报