Hi. I’m new here, and new at programming Ruby. I have a question about
it though.
Is there a possible way to write forms in HTML, and then read them using
a Ruby equivalent to the PHP $_GET or $_POST on the page where the
method points?
Hi. I’m new here, and new at programming Ruby. I have a question about
it though.
Is there a possible way to write forms in HTML, and then read them using
a Ruby equivalent to the PHP $_GET or $_POST on the page where the
method points?
Harry Sa wrote:
Is there a possible way to write forms in HTML, and then read them using
a Ruby equivalent to the PHP $_GET or $_POST on the page where the
method points?
Check out Ruby’s CGI library at
http://www.ruby-doc.org/stdlib/libdoc/cgi/rdoc/index.html.
HTH,
Jim
Yes, there is.
On your ruby application endpoint, you would need something like this:
require “cgi”
cgi = CGI.new
value = cgi[‘field_name’] # <== value string for ‘field_name’
And do all sorts of Ruby operations:
fields = cgi.keys # <== array of field names
cgi.has_key?(‘field_name’)
cgi.has_key?(‘field_name’)
cgi.include?(‘field_name’)
On the same scoop of concept you were viewing it, cgi[‘field_name’] it’s
kind of the same as PHP’s $_REQUEST[‘field_name’].
Actually, I extracted that sample above from the cgi module
documentation
somebody else already pointed to you.
Enjoy,
D.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs