title: Stack level too deep
body: <p>Hello I am received a "Stack level too deep" error and I am fairly sure that it is being generated from this model. I know it has something to do with a recursive call, but I have thus far been unable to locate it, thanks.</p>
  
  <pre><code>class Character &lt; ActiveRecord::Base
  
    # Associations
    belongs_to :user
  
    # Validations
    validates :name, :presence =&gt; true, :uniqueness =&gt; true, :length =&gt; 
    { minimum: 2, maximum: 20 }, format: { with: /\A[a-zA-Z]+\Z/ }
    validates :race, :presence =&gt; true
    validates :class, :presence =&gt; true
    validates :user, :presence =&gt; true
  
    def self.races
      ["Human", "Dwarf", "Elven", "Orc", "Undead", "Demon"]
    end
  
    def self.classes
      {
        :fighter =&gt; {strength: 4, endurance: 3, dexterity: -2, charisma: -2, wisdom: -2, intelligence: -3}, 
        :thief   =&gt; {strength: -3,endurance: 2, dexterity: 4, charisma: 2, wisdom: -2, intelligence: 0}, 
        :magi    =&gt; {strength: -3, endurance: -2, dexterity: -2, charisma: 2, wisdom: 3, intelligence: -3}, 
        :ranger  =&gt; {strength: -2, endurance: 2, dexterity: 2, charisma: 0, wisdom: -3, intelligence: 0}, 
        :cleric  =&gt; {strength: 2,endurance: 2, dexterity: -3, charisma: -2, wisdom: 3, intelligence: 2}
      }
    end
  
    def set_class(_class)
      _attributes = Character.classes[_class.downcase]
      transaction do
        self.class = _class.downcase
        _attributes.each do |name, value|
          self.name += value
        end
        self.save
      end
    end
  end
  </code></pre>
  
  <p>Server log:</p>
  
  <pre><code>Started GET "/characters/new" for 127.0.0.1 at 2014-04-04 01:54:14 +0200
    [1m[36mActiveRecord::SchemaMigration Load (0.8ms)[0m  [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
  Processing by CharactersController#new as HTML
    [1m[35mUser Load (1.5ms)[0m  SELECT "users".* FROM "users" WHERE "users"."id" = 1 ORDER BY "users"."id" ASC LIMIT 1
    Rendered shared/_error_messages.html.erb (3.8ms)
    Rendered characters/new.html.erb within layouts/application (38.1ms)
  Completed 500 Internal Server Error in 199ms
  </code></pre>
  
  <p>SystemStackError - stack level too deep:</p>
  
  <pre><code>activerecord (4.0.2) lib/active_record/attribute_methods/read.rb:85:in `'
  </code></pre>