setting primary key for a database not named “:id”

大城市里の小女人 提交于 2019-12-01 06:34:05

Sets the name of the primary key column.

self.primary_key = "product_code"

self.primary_key returns what rails currently thinks is the primary key and hence takes no arguments. If you want to set the primary key, use self.primary_key = 'blah'.

Earlier versions of rails also supported set_primary_key 'blah', but this was deprecated in rails 3.2.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!