# Is there a utility tool to check the convention between DB t

**URL:** <https://www.ruby-forum.com/t/is-there-a-utility-tool-to-check-the-convention-between-db-t/91435>\
**Category:** Rails\
**Created:** [April 9, 2007, 4:34am UTC](https://www.ruby-forum.com/t/is-there-a-utility-tool-to-check-the-convention-between-db-t/91435 "2007-04-09T04:34:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![allen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/bbce88/32.png) [@allen](https://www.ruby-forum.com/u/allen)\
**Post date:** [April 9, 2007, 4:34am UTC](https://www.ruby-forum.com/t/is-there-a-utility-tool-to-check-the-convention-between-db-t/91435/1 "2007-04-09T04:34:48Z")

</div>

Say that I could just enter the AR model’s name, and it will output  
the DB table’s name according to rails’ default convention. Thanks.

---

<div class="post-metadata">

**Author:** ![allen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/bbce88/32.png) [@allen](https://www.ruby-forum.com/u/allen)\
**Post date:** [April 9, 2007, 5:28am UTC](https://www.ruby-forum.com/t/is-there-a-utility-tool-to-check-the-convention-between-db-t/91435/2 "2007-04-09T05:28:51Z")

</div>

The tableize method will return the table-convention-version of a  
string; this means you could do something like the following:

def table\_name(model)  
model.to\_s.tableize # stringify a class name and tableize it  
end

table\_name(User)

> > users  
> > table\_name(Session)  
> > sessions  
> > table\_name(TeamMember)  
> > team\_members

–Jeremy

On 4/8/07, allen [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Say that I could just enter the AR model’s name, and it will output  
> the DB table’s name according to rails’ default convention. Thanks.
> 
> >

–  
[http://www.jeremymcanally.com/](http://www.jeremymcanally.com/)

My free Ruby e-book:  
[http://www.humblelittlerubybook.com/book/](http://www.humblelittlerubybook.com/book/)

My blogs:

> **[Site not found · DreamHost](http://www.mrneighborly.com/)**
>
> The owner of this domain has not yet uploaded their website.

[http://www.rubyinpractice.com/](http://www.rubyinpractice.com/)

---

<div class="post-metadata">

**Author:** ![allen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/bbce88/32.png) [@allen](https://www.ruby-forum.com/u/allen)\
**Post date:** [April 9, 2007, 5:52am UTC](https://www.ruby-forum.com/t/is-there-a-utility-tool-to-check-the-convention-between-db-t/91435/3 "2007-04-09T05:52:52Z")

</div>

Thanks a lot!

On Apr 9, 11:27 am, “Jeremy McAnally” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
