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.
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 [email protected] 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: