Home Rails Oracle的tableprimaryid一定要指定,否则会出现typeerror:nilisnotasymbolnorastring
Post
Cancel

Rails Oracle的tableprimaryid一定要指定,否则会出现typeerror:nilisnotasymbolnorastring

参考:  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
This post is licensed under CC BY 4.0 by the author.