• How to use Get/Post variables in Ruby?
    17 replies, posted
Hey guys, So, as the title states, how do I retrieve the values of the get/post variables which were submitted by the form, on the next page, in Ruby? Ex: [HTML] <form method="post" action="test.erb"> <input type="text" name="textbox"> <input type="submit" value="clickme"> </form> [/HTML] What ruby code do I need on the other page to take the post value of the text in the textbox on the last page? Without using Ruby on rails, by the way.
I'm not sure you understand what Ruby is...
What ruby web framework are you using?
Rhomobile, for making multi-platform apps. And no, I don't fully understand what Ruby is...
Btw, not having 'get and post variables' built in is one of the things that makes ruby better than php
I still have to use it, and no way of using php (not to cause a shitstorm, stay on-topic), so how would you guys take this challenge? [editline]11th April 2012[/editline] Alright then, the problem is this: I have an unordered list, for each item a different page has to be displayed, but I generate the list via Ruby, and I wanted to use a page that redirects to the page I want to go to, using get or post. [editline]11th April 2012[/editline] And I can't do it directly, because of the Rhomobile framework. It uses controllers, and I can only directly link to the index.erb of the page I want to go to, and to sort stuff out I'd need some way of knowing which item in my list was clicked in order to know what page to display next.
[QUOTE=swift and shift;35523155]Btw, not having 'get and post variables' built in is one of the things that makes ruby better than php[/QUOTE] lmfao what the fuck
Well, thanks anyway guys, I figured out some ways to go around it, and still have the same effect.
[QUOTE=eternalflamez;35537154]Well, thanks anyway guys, I figured out some ways to go around it, and still have the same effect.[/QUOTE] how did you solve your problem?
Using javascript to take the get values, instead. [CODE]<script type="text/javascript"> function getQueryParams(qs) { qs = qs.split("+").join(" "); var params = {}, tokens, re = /[?&]?([^=]+)=([^&]*)/g; while (tokens = re.exec(qs)) { params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]); } return params; } var $_GET = getQueryParams(document.location.search); </script>[/CODE] The value I needed was then found in $_GET['q'] (as in url.html?q=foo ) Did that help you?
[QUOTE=eternalflamez;35537798]Using javascript to take the get values, instead. [CODE]<script type="text/javascript"> function getQueryParams(qs) { qs = qs.split("+").join(" "); var params = {}, tokens, re = /[?&]?([^=]+)=([^&]*)/g; while (tokens = re.exec(qs)) { params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]); } return params; } var $_GET = getQueryParams(document.location.search); </script>[/CODE] The value I needed was then found in $_GET['q'] (as in url.html?q=foo ) Did that help you?[/QUOTE] I didn't need any help. Just curious.
[QUOTE=Catdaemon;35525981]lmfao what the fuck[/QUOTE] are you serious
[QUOTE=Catdaemon;35525981]lmfao what the fuck[/QUOTE] ruby is a general-purpose scripting language. it's adaptation for web development is one of its many purposes- it was not specifically designed for web apps, and therefore does not have GET and POST variables built in. To me, this makes ruby far better than just PHP.
Uh oh here it comes. [editline]12th April 2012[/editline] Did I ask for a php - ruby discussion?
[QUOTE=eternalflamez;35538933]Uh oh here it comes. [editline]12th April 2012[/editline] Did I ask for a php - ruby discussion?[/QUOTE] Whether you asked for one or not is irrelevant. This is Facepunch web dev lol, just prepare your body...
I did not ask for this! Please redirect the php shitstorm here? [url]http://facepunch.com/threads/1176831?p=35539062[/url] "the php appreciation thread" :v:
[QUOTE=Ac!dL3ak;35538916]ruby is a general-purpose scripting language. it's adaptation for web development is one of its many purposes- it was not specifically designed for web apps, and therefore does not have GET and POST variables built in. To me, this makes ruby far better than just PHP.[/QUOTE] yeah pretty much this. I don't want to have to pretend to be a web page when I'm writing a terminal program
$_GET['STDIN']
Sorry, you need to Log In to post a reply to this thread.