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.
on 2007-04-09 04:34
on 2007-04-09 05:28
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 <firstname.lastname@example.org> 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/
on 2007-04-09 05:52
Thanks a lot! On Apr 9, 11:27 am, "Jeremy McAnally" <jeremymcana...@gmail.com>