title: Best Way to initialize a instance variable in Rails
body: <p>I'm having trouble initializing instance variables in Rails, need to use a variable in different methods, but this needs to be initialized beforehand, eg:</p>
  
  <pre class="lang-rb prettyprint-override"><code>class Test &lt; ActiveRecord::Base    
    @test = 1
  
    def testing
      @test+1
    end    
  end
  
  t = Test.new
  t.testing
  </code></pre>
  
  <p>I get the follow error:</p>
  
  <pre><code>test.rb:4:in `testar': undefined method `+' for nil:NilClass (NoMethodError)
      from test.rb:9:in `&lt;main&gt;'
  </code></pre>
  
  <p>Is there a more elegant way to initialize a variable without using the <code>after_initialize</code>?:</p>