Hi;
I'm a newbie and I would appreciate tips that get me startet.
I want to use Ruby serverside. I got eRuby to run with my local Apache;
1. how can I require classes with eRuby?
Ruby code embedded in HTML .rhtml files gets processed without a
problem.
But: when I try to instantiate objects from classes that are not
contained in the file by writing
require "theclass"; I get a load error. I put .rb files with class code
in the same directory, and require them from embedded code in .rhtml
files; is that possible with eRuby?
Here is my code, which doesn't work, but gives
(eval): No such file to load -- calc.rb (LoadError)
:
--------------
*.rhtml:
--------
<html>
...
<%
require 'calc.rb'
num = Calc.new
print num.half(8)
%>
...
</html>
----------------
calc.rb in the same dir:
-----
class Calc
def half(number)
number / 2
end
end
----------------
Also something like Time.new doesn't work, but I think I need to load
all the classes to the
server.
But how to refer to them / use them from other .rhtml files?
When the class is embedded too, it works; but I don't want to include
all classes in all files:
<html>
........
<%
class Calc
def half(number)
number / 2
end
end
%>
........
<%
num = Calc.new
print num.half(8)
%>
...
</html>
2. What are the advantages and limitations of eRuby?
Maybe it's better to install Ruby (not eRuby), and not use embedded
code?
3. Where can I get a cheap hosting account featuring Ruby? (or eRuby; or
both)
4. How to install Ruby (not eRuby) on Apache?
The following didn't work with my local Apache:
AddType application/x-httpd-Ruby .rb
Action application/x-httpd-Ruby "/cgi-bin/Ruby.exe"
5. Ruby in HTML
I would like to embed Ruby in XHTML (the current version of HTML), but
<% a = 4 %>
is not well-formed XML.
It would be nice, if eRuby would parse code embedded in
<?Ruby a = 4 ?>
like with PHP; this way, it can also be embedded in SVG, XML, etc.
How to embed it in a way that's well-formed XML?
Tobi
--
Tobias Reif
http://www.pinkjuice.com/myDigitalProfile.htm