Rails polymorphic naming convention

I'm trying to figure out what to name a polymorphic association and not coming up with good options. The class that will contain the polymorphic association is called LicenseBatch , and if it weren't polymorphic, the foreign key would just be owner_id . It seems that the go-to polymorphic name would be ownerable , but what if I have another class that is ownable? I'd like this to be more specific, but things like batch_ownerable sound awkward.

Any suggestions or similar situations you have seen before?


Try to put a name that automatically refers to the model name, so if the model is Comment I would use commentable_type and commentable_id. For this specific case I would use:

licensable_batch_type and licensable_batch_id

链接地址: http://www.djcxy.com/p/22358.html

上一篇: hadoop / yarn和非并行任务并行化

下一篇: Rails多态命名约定