# Problem with set\_table\_name

**URL:** <https://discuss.rubyonrails.org/t/problem-with-set-table-name/39768>\
**Category:** rubyonrails-talk\
**Created:** [February 25, 2009, 1:22pm UTC](https://discuss.rubyonrails.org/t/problem-with-set-table-name/39768 "2009-02-25T13:22:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [February 25, 2009, 1:22pm UTC](https://discuss.rubyonrails.org/t/problem-with-set-table-name/39768/1 "2009-02-25T13:22:34Z")

</div>

Dear friends, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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"

&nbsp;&nbsp;&nbsp;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:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [February 25, 2009, 2:12pm UTC](https://discuss.rubyonrails.org/t/problem-with-set-table-name/39768/2 "2009-02-25T14:12:31Z")

</div>

> > > D.table\_name
> 
> =\> "orders"
> 
> &nbsp;&nbsp;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
