title: Get table name from ActiveRecord
body: <p>I used <code>ActiveRecord::Base.set_table_name</code> to set my table name on a dynamically created ActiveRecord class. Now I need to know how to get that value later. The api docs don't mention anything on how to do this. Also, I can't derive the table name off the ActiveRecord class name because they are keyed differently than the table name.</p>
  
  <p>Here is a better example of what I am doing</p>
  
  <pre><code>table_klass = Class.new(ActiveRecord::Base)
      ActiveRecord::Base.const_set(const_name,table_klass)
      app = @app
      table_klass.class_eval do
        after_save do
          @@channel.push self
        end
        set_table_name t.server_table
        establish_connection(
          :adapter  =&gt; "mysql2",
          :host     =&gt; app.db_host,
          :username =&gt; app.db_user,
          :password =&gt; app.db_pass,
          :database =&gt; app.db_name
        )
      end
  </code></pre>
  
  <p>In this case, if the <code>const_name</code> = Test  and the database name is Database it should create a class of ActiveRecord::Base::DatabaseTest, which it does. But when I call table_name on it I get undefined local variable or method. Do I need to call table_name on the class?</p>
  
  <p><strong>Update:</strong>
  I got it working by calling <code>instance.class.table_name</code></p>