cgi question

B

Boris Glawe

Hi, the following code results in NoMethodError, when being executed as a cgi
script.

The reason is the line "+ cgi.b {"hello world in bold"}" at the bottom.

Can anybody explain me, what's happening here?
The preceding block simply returns a (html) string, containing a form, which is
concatenated with "<b>hello world in bold</b>"

Do you have any idea?


thanks Boris


#!/usr/bin/ruby

require "cgi"


cgi=CGI.new("html4")

cgi.out {

CGI.pretty(
cgi.html{
cgi.head{
cgi.title{ "testpage" }
} +
cgi.body{
cgi.form{
cgi.table( {'border' => '1'} ){
cgi.tr {
cgi.td{ "hello"} +
cgi.td {"world"}
} # end tr
} # end table
} # end form
+ cgi.b {"hello world in bold"}
} # end head
} # end html
) # end CGI#pretty

} # end cgi.out
#############################################################

the error message:

# ./test.rb
(offline mode: enter name=value pairs on standard input)
../test.rb:24: undefined method `+@' for "<B>hello world in bold</B>":String
(NoMethodError)
from ./test.rb:15:in `body'
from ./test.rb:15
from ./test.rb:11:in `html'
from /usr/lib/ruby/1.8/cgi.rb:1653:in `html'
from /usr/lib/ruby/1.8/cgi.rb:1653:in `html'
from ./test.rb:11
from ./test.rb:8:in `out'
from ./test.rb:8
 

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,776
Messages
2,569,603
Members
45,185
Latest member
GluceaReviews

Latest Threads

Top