Forum: Ruby CGI class question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
unknown (Guest)
on 2005-12-31 19:23
(Received via mailing list)
hi,

when i execute the following
....
cgi.body{
                        cgi.h1{"huhu"} +
                        cgi.p{"Wasn los ?"} +
                        cgi.p{
                                Dir["*.*"].each{ |f|
                                        "huhu "
                                }
                        }
                }
....

i never got any "huhu" but

<BODY>
		<H1>
			huhu
		</H1>

		<P>
			Wasn los ?
		</P>
		<P>
			index.rbtest_dir.rbstyle.css
		</P>
	</BODY>

what do i wrong ?

thanks for helping me.

many regards,

lars
Stephen W. (Guest)
on 2005-12-31 19:32
(Received via mailing list)
On Dec 31, 2005, at 9:22 AM, removed_email_address@domain.invalid wrote:

> i never got any "huhu" but
>
> 		<H1>
> 			huhu
> 		</H1>

Correct me if I'm wrong, but it looks like it's there.  ???

--Steve
James B. (Guest)
on 2005-12-31 20:23
(Received via mailing list)
In

cgi.p{
  Dir["*.*"].each{ |f|
    "huhu "
   }
}

cgi.p is emitting the return value of

Dir["*.*"].each{ |f|
    "huhu "
   }

which is the set of file names, not the string "huhu "

Try this as a simple script to see this:

   puts Dir["*.*"].each{ |f| "huhu " }


You may want


  Dir["*.*"].each{ |f|
   cgi.p{ "huhu " }
   }

Or something like that.

James


--

http://www.ruby-doc.org       - Ruby Help & Documentation
http://www.artima.com/rubycs/ - Ruby Code & Style: Writers wanted
http://www.rubystuff.com      - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com     - Playing with Better Toys
http://www.30secondrule.com   - Building Better Tools
This topic is locked and can not be replied to.