Currently I am working on project like web analytic using rails 3.2.3
I have two server, one is running on port 3001 and other one running on port 3000.
Here port 3001 is the server (let’s say this is Google web analytic server) and port 3000 server is the end user (let’s say this is your site). Now I need to get
request object from port 3000.
If I will write below code I can get the Browser details.
application.html.erb – This is user side code.
<script type="text/javascript"
src="http://localhost:3001/tracks/track_client?bwname=<%= request.env["HTTP_USER_AGENT"] %>">
</script>
This is the server side coce
def track_client
params.each do |key,value|
Rails.logger.warn "Param #{key}: #{value}"
end
end
{bwname=>Mozilla/5.0 (Windows NT 6.1", " WOW64) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2}
But I need user’s request object with all properties not specific. like I need other properties too like
"GATEWAY_INTERFACE", "PATH_INFO", "QUERY_STRING", "REMOTE_ADDR", "REMOTE_HOST", "REQUEST_METHOD", "REQUEST_URI", "SCRIPT_NAME", "SERVER_NAME", "SERVER_PORT", "SERVER_PROTOCOL", "SERVER_SOFTWARE", "HTTP_HOST", "HTTP_USER_AGENT",
"HTTP_ACCEPT", "HTTP_ACCEPT_LANGUAGE", "HTTP_ACCEPT_ENCODING", "HTTP_DNT"=>"1", "HTTP_CONNECTION", "HTTP_COOKIE", "HTTP_IF_NONE_MATCH", "HTTP_CACHE_CONTROL"
Along with this I need some other params too like something like this
<script type="text/javascript"
src="http://localhost:3001/tracks/track_client?userid=1234&bwname=<%= request.env %>">
</script>
Are you looking for
requestobject?Please check here
http://techoctave.com/c7/posts/25-rails-request-environment-variables