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

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top