Back

rails - oracle的table primary id 一定要指定,否则会出现TypeError: nil is not a symbol nor a string

发布时间: 2018-12-15 02:02:00

参考:  https://stackoverflow.com/questions/40623598/rails-typeerror-nil-is-not-a-symbol-nor-a-string-when-updating

一个项目, 数据库使用了 oracle, 

table 主键 是  cid ,  不是 id , 

所以在 做 update操作的时候, 出现了错误提示:    TypeError: nil is not a symbol nor a string

不google的话,完全没有头绪.  (我的关键词应该是这个 , 加上rails) 

所以,一定要指定 primary_id啊.

class YourDependentRecord < ApplicationRecord
  self.primary_key = 'user_id'
end

Back