title: How can I create a field using the id from the same row in ActiveRecord Ruby
body: <p>-----UPDATE-----</p>
  
  <p>Well, seems that the problem was in <code>last.id</code>. When database is created works OK, but when not fails. Now the question is different: How can I create a field using the id from the same row?</p>
  
  <p>--------ORIGINAL------</p>
  
  <p>I'm working with active record in pure ruby (without Rails), and I'm literally getting crazy with this.
  This is my code</p>
  
  <pre><code>class Enviroment &lt; ActiveRecord::Base
      #self.table_name = 'enviroments'
      self.connection.create_table(:enviroments, :force=&gt;true) do |t|
          t.column :name, :string, :default=&gt;'env-'+ (last.id-1).to_s
          t.column :ssh, :string, :default=&gt;nil
      end
  end
  </code></pre>
  
  <p>and here the error:</p>
  
  <pre><code>ActiveRecord::StatementInvalid: Could not find table 'enviroments'
  from /usr/lib/ruby/gems/1.8/gems/activerecord-3.2.3/lib/active_record/connection_adapters/sqlite_adapter.rb:465:in `table_structure'
  </code></pre>
  
  <p>if I use<code>self.table_name = 'enviroments'</code> still not working. I've updated the gems and neither. 
  I'm newbie with ruby and databases, but I can't understand this problem, I think this same code worked in the past :S</p>