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