title: Ruby String to Class Name
body: <p>I am trying to create a new class to that will inherit from <code>ActiveRecord::Base</code> the class needs to be dynamically generated from a string</p>
  
  <pre><code>"general_systems".camelize.singularize = Class.new &lt; ActiveRecord::Base
  </code></pre>
  
  <p>However I keep getting the error:</p>
  
  <pre><code>undefined method `singularize=' for "GeneralSystems":String
  </code></pre>
  
  <p>I've also tried to <code>constantize</code> the string</p>
  
  <pre><code>&gt;&gt; foo = "general_systems".camelize.singularize
  =&gt; "GeneralSystem"
  &gt;&gt; foo.constantize
  NameError: uninitialized constant GeneralSystem
      from /var/lib/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/inflector/methods.rb:124:in `block in constantize'
      from /var/lib/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/inflector/methods.rb:123:in `each'
      from /var/lib/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/inflector/methods.rb:123:in `constantize'
      from /var/lib/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/core_ext/string/inflections.rb:43:in `constantize'
      from (irb):4
      from /usr/bin/irb:12:in `&lt;main&gt;'
  &gt;&gt; foo.constantize = Class.new
  NoMethodError: undefined method `constantize=' for "GeneralSystem":String
      from (irb):5
      from /usr/bin/irb:12:in `&lt;main&gt;'
  </code></pre>
  
  <p>Any help would be greatly appreciated.</p>