# How does table\_name static method work?

**URL:** <https://www.ruby-forum.com/t/how-does-table-name-static-method-work/118864>\
**Category:** Rails\
**Created:** [October 31, 2007, 7:22pm UTC](https://www.ruby-forum.com/t/how-does-table-name-static-method-work/118864 "2007-10-31T19:22:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![uncle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/e5b9ba/32.png) [@uncle](https://www.ruby-forum.com/u/uncle)\
**Post date:** [October 31, 2007, 7:22pm UTC](https://www.ruby-forum.com/t/how-does-table-name-static-method-work/118864/1 "2007-10-31T19:22:58Z")

</div>

There has to be a simple explanation for this.

I can do this to get the table name behind a model

> > User.table\_name  
> > =\> “users”

Great. But looking at the table\_name code in active\_record/base.rb,  
the table\_name method is not static (no self.)!

```
  def table_name
    reset_table_name
  end

```

So why can I call table\_name as a static method ???

---

<div class="post-metadata">

**Author:** ![uncle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/e5b9ba/32.png) [@uncle](https://www.ruby-forum.com/u/uncle)\
**Post date:** [October 31, 2007, 7:41pm UTC](https://www.ruby-forum.com/t/how-does-table-name-static-method-work/118864/2 "2007-10-31T19:41:41Z")

</div>

> ```
> def table_name
> reset_table_name
> end
> 
> ```
> 
> So why can I call table\_name as a static method ???

Scroll up to around line 353 and you’ll see this line:

```
 class << self # Class methods

```

So if you remove everything else you really have this:

module ActiveRecord  
class Base  
class \<\< self # Class methods  
def table\_name  
…  
end  
end  
end  
end
