Hi all, I have some problems using erb(o erubis) + cgi
I am able to use single rb files or rhtml, but when I try to use a structure
like that:
file.rb+file.eruby
I have an internal server error (500)
I know, these problems are really by newbie.
I show you my files.
···
----------
file.rb
-----------
#!/usr/bin/ruby
require 'rubygems'
require 'erubis'
input = File.read('file.eruby')
eruby = Erubis::Eruby.new(input, :trim=>false)
list = ['aaa', 'bbb', 'ccc']
puts eruby.result(binding()) ## using eruby.evaluate(...)
--------------
file.eruby
-------------
<ul>
<% for item in list %>
<li>
<%= item %>
</li>
<% end %>
</ul>
opening file.rb in my browser (in the shell it works fine, showing me the
html code) , apache server responds to:
[error] mod_ruby: error in ruby
[error] mod_ruby:
/usr/lib/ruby/gems/1.8/gems/erubis-2.4.1/lib/erubis/evaluator.rb:62:in
`eval': Insecure operation - eval (SecurityError)
[error] mod_ruby: from
/usr/lib/ruby/gems/1.8/gems/erubis-2.4.1/lib/erubis/evaluator.rb:62:in
`result'
[error] mod_ruby: from /home/indaco/public_html/file.rb:12
[error] mod_ruby: from /usr/lib/ruby/1.8/apache/ruby-run.rb:53:in `load'
[error] mod_ruby: from /usr/lib/ruby/1.8/apache/ruby-run.rb:53:in
`handler'
-------------------------------
My httpd.conf is like:
-------------------------------
ScriptAlias /cgi-bin/ /usr/local/apache2/cgi-bin/
<IfModule mod_userdir>
UserDir public_html
</IfModule>
<Directory /home/indaco/public_html/cgi-bin/>
Options ExecCGI
SetHandler cgi-script
</Directory>
<Directory /home/indaco/public_html/>
Options ExecCGI
SetHandler cgi-script
AddHandler cgi-script .rb .rbx .cgi .pl
</Directory>
# If the ruby module is installed, this will be enabled.
<IfModule mod_ruby.c>
# # for Apache::RubyRun
RubyRequire apache/ruby-run
# # for Apache::ERubyRun
RubyRequire apache/eruby-run
# # for Apache::ERbRun
RubyRequire apache/erb-run
# # for debug
RubyRequire auto-reload
# exec files under /ruby as ruby scripts.
<Location /ruby>
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance
Options +ExecCGI
</Location>
#
# # handle files under /eruby as eRuby files by eruby.
<Location /eruby>
SetHandler ruby-object
RubyHandler Apache::ERubyRun.instance
</Location>
#
# # handle files under /erb as eRuby files by ERb.
<Location /erb>
SetHandler ruby-object
RubyHandler Apache::ERbRun.instance
</Location>
# exec *.rb as ruby scripts.
<Files *.rb>
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance
</Files>
# exec *.rbx as ruby scripts.
<Files *.rbx>
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance
</Files>
#
# # handle *.rhtml as eruby files.
<Files *.rhtml>
SetHandler ruby-object
RubyHandler Apache::ERubyRun.instance
</Files>
</IfModule>
Please help me in some way!
Thanks