title: How to create a variable name from the value of a string in Ruby on Rails?
body: <p>I want to create an instance variable in a controller to be used in the view:</p>
  
  <pre><code>foo = "bar"
  instance_variable_set("#{foo}", "cornholio")
  </code></pre>
  
  <p>In the view, use @bar so that:</p>
  
  <pre><code>@bar =&gt; "cornholio"
  </code></pre>
  
  <p>This generates an error: <code>'bar' is not allowed as an instance variable name</code></p>
  
  <p>Working in Rails 3.1</p>