I'm using devise and as per the documentations recommendations I have a User model (for devise) and a Profile model for user data such as names, job etc. Why is it considered "not so good" to just store all these attributes on the devise User model table. Just curious.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Adding fields to tables specified by an external source could result in migration errors in future versions of the gem if the gem changes the table definition.
Think of the users table as an implementation detail of the devise gem. It's generally a bad idea to modify the source of an external library because it makes upgrades difficult or impossible.
回答2:
Separation of concern! The User
model is used by devise
(which handles
app auth and access) while the Profile
model handles all the business logic.