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


#1

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.


#2

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 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/

My free Ruby e-book:
http://www.humblelittlerubybook.com/book/

My blogs:
http://www.mrneighborly.com/
http://www.rubyinpractice.com/


#3

Thanks a lot!

On Apr 9, 11:27 am, “Jeremy McAnally” removed_email_address@domain.invalid