Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id
这种问题如果是在一个事务中,你使用Customer.new的话,然后你又对customer进行一系列的操作,如下示例:
然后当你在save的时候就会报以上的错误
customer = Customer.new(attr)
customer.channel_type = "101"
customer.channel_id = 101
customer.sales_id = 101
customer.save!
#此处会报错
此时的解决办法就是把new 改为 create然后就可以了
customer = Customer.create(attr)
customer.channel_type = "101"
customer.channel_id = 101
customer.sales_id = 101
customer.save!
如此代码为正确
具体原因尚未了解,希望高人解答!
分享到:
相关推荐
一个关于数组越界、字典key与value为nil情况下导致的低级错误的线上Crash的避免的仓库
given a NIL-ID, which consists of "NIL" plus a four-digit zero-padded sequentially assigned integer (e.g. NIL-0001, NIL-0002). Both the entities with an entity node ID of "E" type and "NIL" type ...
which the Assign method is called. - ADD: In TIdPool (module FlexUtils), added the method NextUsed (allows iterating all taken identifiers). - ADD: Added the method TEnumProp.SetItem for convenience...
清理字典转模型后模型中的nil,属性多于字典,服务器返回为null等情况
lua-cjson lua的cjson库 decode略做修改 结果中null还原成nil
Go文档中说明:nil是预定义的标识符,代表指针,通道,函数,接口,映射或者切片的零值,并不是Go的关键字之一。 还有,nil只能赋值为以上的几个类型,若赋值给基础类型,则会引发panic 2.nil的作用 指针(pointer)...
#4 in Big Data Businesses #5 in Information Management (Kindle Store) This book fills the need for a concise and conversational book on the growing field of Data Analytics and Big Data. Easy to read ...
特别是,我们找到了带电Solv和Nil几何层的解决方案。 我们还发现Nil黑洞具有超标度违规。 对于我们所有的解决方案,我们计算相应双场理论的热电直流输运系数。 我们发现没有超标度违规的Solv和Nil黑洞对金属是双重...
接口: 接口类型 是由一组方法签名定义的集合。 接口类型的变量可以保存任何实现了这些方法的值。 类型通过实现一个接口的所有方法来实现该接口。既然无需专门显式声明,也就没有“implements”关键字。 接口也是值...
IOS 基础之nil,NULL,NSNULL区别详解 ① nil:一般赋值给空对象。 ② NULL:NULL 是一个通用指针(泛型指针)。 一般赋值给 nil 之外的其他空值。如SEL等。 ③ NSNULL:[NSNull null] 是一个对象,他用在不能使用 ...
用于CT扫描的二值化图像多重分形计算
reason: 'UITableView dataSource returned a nil cell for row at index path:... ... ///找到这段英文中出现的自己的类名 如: >>' 通过异常名字和控制台给出的错误,大致可以分析到是单元行出错(因为tableView...
nil 是 ObjC 对象的字面空值,对应 id 类型的对象,或者使用 @interface 声明的 ObjC 对象。 例如: NSString *someString = nil; NSURL *someURL = nil; id someObject = nil; if (anotherObject == nil) // do ...
概述Emacs 的持久存储,失败时返回 nil。... 100解释这是的包装器,提供“软”获取和存储例程,这些例程永远不会抛出错误,而是在失败时返回 nil。 此库没有最终用户界面。 它只对其他 Lisp 代码有用。 提
如下所示的配置结构: %NavigationTree.Node{ name: string, # the node's name, like "About Us" url: nil or string, # will be set on startup, but may be overridden controller: nil or string, # would be ...
从对象和数组中删除nil值。 将所有其他nil值转换为null。 例子 var noNil = require ( 'no-nil' ) ; var input = [ 1 , undefined ] ; console . log ( noNil ( input ) ) ; // [1]; ##执照 The MIT License ...
This is only useful if ObjRef = nil and so no ObjRef.Filename can be set. + TParagraph.GetSubText now has optional parameter to disable the object reference char codes #1, #2 and #3 * ...
安装将此行添加到应用程序的 Gemfile 中: gem 'mr_to_nil' 然后执行: $ bundle或者自己安装: $ gem install mr_to_nil用法 [ :random , :array ] . to_nil # nil31337 . to_nil # nil"Yet another shitty gem" . ...
Mainly minor improvements and some small bugfixes, but also a new 'ultimap like' feature called Code Filter for which you don't need any special hardware for. (Just an extensive list of addresses) ...
相信有不少朋友想知道,在 Objective-C 中 nil 和 Nil 以及 NULL 的区别。最重要的是,在面试中还有不少朋友常会被问到。现在小编在这里统一详细说明。