Forum: Ruby Using ERb with $SAFE=4

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Andy Morrow (Guest)
on 2007-04-03 02:48
(Received via mailing list)
I'm trying to use ERb to evaluate a template written by end users in
a Rails application I'm writing. Here's my code:

require 'erb'
template = "<%= 'Testing 1 2 3...' %>".taint #because it will be user
input in the final app
e =, 4)
m =
puts m

Here's what I get:
/usr/local/lib/ruby/1.8/erb.rb:739:in `eval': Insecure: can't modify
trusted binding (SecurityError)
         from /usr/local/lib/ruby/1.8/erb.rb:741:in `value'
         from /usr/local/lib/ruby/1.8/erb.rb:741:in `result'
         from /usr/local/lib/ruby/1.8/erb.rb:724:in `run'
         from tester.rb:4

What am I doing wrong?
Andy Morrow
This topic is locked and can not be replied to.