[colug-432] Ruby ActiveRecord joined tables
Rob Funk
rfunk at funknet.net
Thu Aug 13 09:20:00 EDT 2015
Rob Funk wrote:
> Specifically, ActiveRecord assumes that tables are named as plurals
> (e.g. "songs"), and foreign keys are singular tablename underscore id
> (e.g. "song_id").
It also assumes that table name is the plural version of the class
name. I *think* the FK name is assumed to be based on the other
*class* name (rather than the other *table* name), but since those
usually match it's a distinction I've rarely had to think about.
Overriding all of ActiveRecord's assumptions is possible, but you'll
have to do it for pretty much every piece, and most documentation
assumes you're using the standard conventions.
This is part of what people mean when they say Rails is *opinionated*.
More information about the colug-432
mailing list