(noob) Help with variables

J

James Dewey

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') %>


<html>
<head>
<title>Cloud Files Manager</title>
</head>
<body bgcolor="#000000">
<font color="#33FF00">

<center>
<h1>List of Containers:</h1>
<%
cf::list_containers::each do |listcont|
puts listcont + "<br>"
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.
 
R

Robert Klemme

2010/3/11 James Dewey said:
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 =3D CloudFiles::Connection::new('ryuujinx','APIKEYREMOVED') %>


<html>
=A0 =A0 =A0 =A0<head>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0<title>Cloud Files Manager</title>
=A0 =A0 =A0 =A0</head>
<body bgcolor=3D"#000000">
<font color=3D"#33FF00">

<center>
<h1>List of Containers:</h1>
<%
cf::list_containers::each do |listcont|
=A0 =A0 =A0 =A0puts listcont + "<br>"
end
%>

I believe you rather want

<% cf::list_containers::each do |listcont| %>
<%=3D listcont %><br>
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
The next step I would want to do is container =3D
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

--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
 
J

James Dewey

Robert said:
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


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

<form action="somepage.php" method="post">
<input type="text" name="somevar">
<input type="submit">
</form>

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?
 
R

Robert Klemme

2010/3/11 James Dewey said:
Robert said:
Not sure what you mean by "grab variables". =A0If you need to evaluate
HTML form variables you can use
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

<form action=3D"somepage.php" method=3D"post">
<input type=3D"text" name=3D"somevar">
<input type=3D"submit">
</form>

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?

Google for "ruby cgi post" reveals this as first hit:
http://www.tutorialspoint.com/ruby/ruby_web_applications.htm

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

Cheers

robert

--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,076
Latest member
OrderKetoBeez

Latest Threads

Top