# (noob) Help with variables

**URL:** <https://www.ruby-forum.com/t/noob-help-with-variables/184964>\
**Category:** Ruby\
**Created:** [March 11, 2010, 5:09am UTC](https://www.ruby-forum.com/t/noob-help-with-variables/184964 "2010-03-11T05:09:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimdeuc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b77776/32.png) [@jimdeuc](https://www.ruby-forum.com/u/jimdeuc)\
**Post date:** [March 11, 2010, 5:09am UTC](https://www.ruby-forum.com/t/noob-help-with-variables/184964/1 "2010-03-11T05:09:18Z")

</div>

I’m trying to make what amounts to a cloud files manager using the ruby  
API. In the end I want login via MySQL and all that fun stuff, but for  
now I want it to just -work-. I’m using eruby loaded via CGI on apache.

So I was able to list the containers on my account:

\<% require ‘rubygems’  
require ‘cloudfiles’  
cf = CloudFiles::Connection::new(‘ryuujinx’,‘APIKEYREMOVED’) %\>

 Cloud Files Manager 
# List of Containers:
\<% cf::list\_containers::each do |listcont| puts listcont + "  
" end %\>

I could make it do it in a select menu with a form, etc, but my problem  
is even if I do post it to a new page, I have no idea how to grab the  
variables or anything.

The next step I would want to do is container =  
cf::container(‘SELECTEDCONTAINER’) for further manipulation such as the  
ability to manage objects inside the container, but I’m kind of lost.

---

<div class="post-metadata">

**Author:** ![jimdeuc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b77776/32.png) [@jimdeuc](https://www.ruby-forum.com/u/jimdeuc)\
**Post date:** [March 11, 2010, 12:56pm UTC](https://www.ruby-forum.com/t/noob-help-with-variables/184964/2 "2010-03-11T12:56:30Z")

</div>

2010/3/11 James D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> cf::list\_containers::each do |listcont|  
> puts listcont + “  
> ”  
> end  
> %\>

I believe you rather want

\<% cf::list\_containers::each do |listcont| %\>  
\<%= listcont %\>  
  
\<% end %\>

> I could make it do it in a select menu with a form, etc, but my problem  
> is even if I do post it to a new page, I have no idea how to grab the  
> variables or anything.

Not sure what you mean by “grab variables”. If you need to evaluate  
HTML form variables you can use  
[http://www.ruby-doc.org/core/classes/CGI.html](http://www.ruby-doc.org/core/classes/CGI.html)

> The next step I would want to do is container =  
> cf::container(‘SELECTEDCONTAINER’) for further manipulation such as the  
> ability to manage objects inside the container, but I’m kind of lost.

Kind regards

robert

---

<div class="post-metadata">

**Author:** ![jimdeuc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b77776/32.png) [@jimdeuc](https://www.ruby-forum.com/u/jimdeuc)\
**Post date:** [March 11, 2010, 7:48pm UTC](https://www.ruby-forum.com/t/noob-help-with-variables/184964/3 "2010-03-11T19:48:57Z")

</div>

Robert K. wrote:

> Not sure what you mean by “grab variables”. If you need to evaluate  
> HTML form variables you can use  
> [http://www.ruby-doc.org/core/classes/CGI.html](http://www.ruby-doc.org/core/classes/CGI.html)
> 
> Kind regards
> 
> robert

Basically I want to be able to get variables from posting forms.

In PHP I would want to do something along the lines of

then on somepage.php use

The var on the last page was\<?php echo $\_POST["somevar"]; ?\>

Only using ruby; in the article you linked I see CGI::Query that could  
probably work if I use the GET method for the form instead of the POST  
method; is there a way to use POST like shown with the php example?

---

<div class="post-metadata">

**Author:** ![jimdeuc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b77776/32.png) [@jimdeuc](https://www.ruby-forum.com/u/jimdeuc)\
**Post date:** [March 12, 2010, 12:57pm UTC](https://www.ruby-forum.com/t/noob-help-with-variables/184964/4 "2010-03-12T12:57:50Z")

</div>

2010/3/11 James D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Basically I want to be able to get variables from posting forms.  
> The var on the last page was\<?php echo $\_POST["somevar"]; ?\>
> 
> Only using ruby; in the article you linked I see CGI::Query that could  
> probably work if I use the GET method for the form instead of the POST  
> method; is there a way to use POST like shown with the php example?

Google for “ruby cgi post” reveals this as first hit:

> **[Ruby Web Applications - CGI Programming](http://www.tutorialspoint.com/ruby/ruby_web_applications.htm)**
>
> Ruby Web Applications CGI Programming - Ruby is a general-purpose language; it can't properly be called a web language at all. Even so, web applications and web tools in general are among the most common uses of Ruby.

Note: Ruby will take care of GET and POST methods  
automatically. There is no separate treament for these two different  
methods.

Cheers

robert
