Is it possible to require a class in an erb template?

erb, require, ruby-on-rails, templates

Solution

First of all do not require gems or libraries in ERB please. Then CGI is required by Rails itself already.

If you want to prevent Rails 3 from auto-escaping consider using

`<%= data.html_safe %>`

instead.

Problem

I have an erb template in which I need to use: CGI.unescapeHTML(someEscapedHTML) So I need to require 'cgi', however the following fails: ``` <% require 'cgi' %> ``` With the error: can't dup NilClass

Original source

Related problems