# Problem with set\_table\_name

**URL:** <https://www.ruby-forum.com/t/problem-with-set-table-name/161322>\
**Category:** Rails\
**Created:** [February 25, 2009, 2:22pm UTC](https://www.ruby-forum.com/t/problem-with-set-table-name/161322 "2009-02-25T14:22:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sarathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@sarathy](https://www.ruby-forum.com/u/sarathy)\
**Post date:** [February 25, 2009, 2:22pm UTC](https://www.ruby-forum.com/t/problem-with-set-table-name/161322/1 "2009-02-25T14:22:34Z")

</div>

Dear friends,  
I ran the following in my console.Assume I already have the  
postgresql connection .

> > class D \< ActiveRecord::Base  
> > end  
> > =\> nil

> > D.set\_table\_name “users”  
> > =\> nil
> 
> > D.column\_names  
> > =\> [“id”, “name”, “fname”, “lname”, “password”, “addr1”, “addr2”,  
> > “city”, “state”, “email”, “created”, “gender”]

> > D.reset\_table\_name  
> > =\> “ds”
> 
> > D.set\_table\_name “orders”  
> > =\> nil
> 
> > D.column\_names  
> > =\> [“id”, “name”, “fname”, “lname”, “password”, “addr1”, “addr2”,  
> > “city”, “state”, “email”, “created”, “gender”]

> > D.table\_name  
> > =\> “orders”

Though I have different columns in “orders” table ,I get the same  
column\_names for “orders” table .

Please help me.

Regards,  
Sarathy

---

<div class="post-metadata">

**Author:** ![sarathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@sarathy](https://www.ruby-forum.com/u/sarathy)\
**Post date:** [February 25, 2009, 3:13pm UTC](https://www.ruby-forum.com/t/problem-with-set-table-name/161322/2 "2009-02-25T15:13:38Z")

</div>

On 25 Feb 2009, at 13:22, Sarathy .n wrote:

> > > D.table\_name  
> > > =\> “orders”
> 
> Though I have different columns in “orders” table ,I get the same  
> column\_names for “orders” table .

ActiveRecord caches the column information - you should probably call  
reset\_column\_information after changing the table name

Fred
