title: Binding in 1.9.2
body: <p>I used to use ERB templates everywhere using the following technique:</p>
  
  <pre><code>def create_from_template(file, template, vars)
    contents = File.read(template(template))
    struct = OpenStruct.new(vars)
    result = ERB.new(contents).result(struct.binding)
    File.open(file, 'w') { |f| f.write result }
  end
  </code></pre>
  
  <p>And I use it the following way:</p>
  
  <pre><code>app = App.new(...)
  create_from_template('new_file', 'template', { :app =&gt; app })
  </code></pre>
  
  <p>So in my template I could have:</p>
  
  <pre><code>&lt;%= app.name %&gt;
  </code></pre>
  
  <p>And it would replace fine in REE 1.8.7, however in 1.9.2 I get the following error:</p>
  
  <pre><code> NameError:
     undefined local variable or method `app' for #&lt;ERB:0x007ffe6b838468&gt;
  </code></pre>
  
  <p><strong>QUESTION:</strong> How can I make this code 1.9.2 compliant?</p>