I’m using webrick (the built-in ruby webserver) to serve .rhtml
files (html with ruby code embedded — like jsp).
It works fine, but I can’t figure out how to access parameters (e.g. http://localhost/mypage.rhtml?foo=bar) from within the ruby code in the .rhtml file.
(note that I’m not using the rails framework, only webrick + .rhtml files)
According to the source code of erbhandler it runs the rhtml files this way:
So the binding should contain a
query(which contains a hash of the query string) and ameta_varsvariable (which contains a hash of the environment, likeSERVER_NAME) that you can access inside the rhtml files (and theservlet_requestandservlet_responsemight be available too, but I’m not sure about them).If that is not the case you can also try querying the CGI parameter
ENV["QUERY_STRING"]and parse it, but this should only be as a last resort (and it might only work with CGI files).