Category: Ruby & Ruby On Rails
eruby using require 'mysql'
Good day! I'm using iis 5.1 on a windows xp sp2 professional OS. I use eruby to convert my .rhtml files to readable html. I used eruby to execute the following rhtml code:
<%
require 'Loop'
require 'cgi'
cgi = CGI.new
tosort = cgi['tosort'].strip
%>
<html>
<head>
</head>
<body>
<form action="show.rhtml" method="post" >
<label>Input comma (,) separated values: <input type="text" name="tosort"></label>
<input type ="submit" value="Send" />
</form>
<%if !tosort.empty? %>
<p> <%=tosort%> <p>
<%
splitted = tosort.split(",",-1)
size = splitted.length
size.times {|v| splitted[v] = splitted[v].to_i }
size.times { |j|
for i in 1...(size - j)
splitted[i], splitted[i - 1] = splitted[i - 1], splitted[i] if splitted[i] < splitted[i - 1]
end
}
splitted.each{|split| puts split}
%>
<%end %>
</body>
</html>
this code works properly. However, when I tried to convert it into using the database with require 'mysql' , IIS sends a file containing the following:
require 'Loop'
require 'cgi'
require 'mysql'
cgi = CGI.new
tosort = cgi['tosort'].strip
print "\n"
print "\n"
print "<html>\n"
print "<head>\n"
print "</head>\n"
print "<body>\n"
print " <form action=\"show.rhtml\" method=\"post\" >\n"
print " <label>Input comma (,) separated values: <input type=\"text\" name=\"tosort\"></label>\n"
print " <input type =\"submit\" value=\"Send\" />\n"
print " </form>\n"
print "\n"
if !tosort.empty? ; print "\n"
print " <p> "; print((tosort)); print " <p>\n"
print " ";
splitted = tosort.split(",",-1)
size = splitted.length
size.times {|v| splitted[v] = splitted[v].to_i }
size.times { |j|
for i in 1...(size - j)
splitted[i], splitted[i - 1] = splitted[i - 1], splitted[i] if splitted[i] < splitted[i - 1]
end
}
splitted.each{|split| puts split}
; print "\n"
end ; print " \n"
print "</body>\n"
print "</html>"----------------------
I suspect there is something wrong with my eruby but I don't know how to fix it. Please help! Thank you and God bless!