# Problem with set\_table\_name

**URL:** <https://www.ruby-forum.com/t/problem-with-set-table-name/148932>\
**Category:** Rails\
**Created:** [September 18, 2008, 1:37pm UTC](https://www.ruby-forum.com/t/problem-with-set-table-name/148932 "2008-09-18T13:37:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [September 18, 2008, 1:37pm UTC](https://www.ruby-forum.com/t/problem-with-set-table-name/148932/1 "2008-09-18T13:37:41Z")

</div>

Dear all,

I am in process of interfacing web with a chat tool.

Iam using rails 2.0.2 and mysql.

i have created a database chat\_development, with table names userinfos,  
clientinfos.

I dont want the defaults, i need to set the table name like, user\_info  
and client\_info. i have used set\_table\_name method like,

class Userinfo \< ActiveRecord::Base  
set\_table\_name “user\_info”  
end

I have even set the environment.rb file like,

ActiveRecord::Base.pluralize\_table\_names = false

when i gave rake db:migrate , all files are migrated well but the table  
names are not changed in my DB. what i need to do to change the table  
names of my own. Please suggest

Thanks in advance

Regards,

Jose Martin

---

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [September 18, 2008, 2:06pm UTC](https://www.ruby-forum.com/t/problem-with-set-table-name/148932/2 "2008-09-18T14:06:17Z")

</div>

On 18 Sep 2008, at 12:37, dare ruby wrote:

> ActiveRecord::Base.pluralize\_table\_names = false
> 
> when i gave rake db:migrate , all files are migrated well but the  
> table  
> names are not changed in my DB. what i need to do to change the table  
> names of my own. Please suggest

Those settings just control what table Rails will try to use for a  
given class - they’ll never change the schema.

If you want to change the schema, write a migration.

Fred

---

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [September 18, 2008, 2:15pm UTC](https://www.ruby-forum.com/t/problem-with-set-table-name/148932/3 "2008-09-18T14:15:01Z")

</div>

> If you want to change the schema, write a migration.

Dear fred,

Thanks for your immediate response, how to perform migration for the  
above. I have no idea? could you please suggest.

Thanks in advance

Regards,  
Jose martin

---

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [September 18, 2008, 3:50pm UTC](https://www.ruby-forum.com/t/problem-with-set-table-name/148932/4 "2008-09-18T15:50:35Z")

</div>

dare ruby wrote:

> > If you want to change the schema, write a migration.
> 
> Dear fred,
> 
> Thanks for your immediate response, how to perform migration for the  
> above. I have no idea? could you please suggest.
> 
> Thanks in advance
> 
> Regards,  
> Jose martin

its simple…

rename\_table(old\_table\_name, new\_table\_name)
