今天在想着怎么样来批量修改
params = [{"id=>"1" ,"name="jj"},{"id=>"2" ,"name="jssj"},{"id=>"4" ,"name="lou"}]
我想把他转换成根据id批量更新的方法然后我去查看base.rb的源码,发现下面这种代码
# Example of updating one record:
# Person.update(15, {:user_name => 'Samuel', :group => 'expert'})
#
# Example of updating multiple records:
# people = { 1 => { "first_name" => "David" }, 2 => { "first_name" => "Jeremy"} }
# Person.update(people.keys, people.values)
感觉可以拿来试试,唯一需要的就是把数组转换成一个hash,
但我按照这种格式后进行update时产生wrong number of arguments (2 for 0) 错误
就算people = { 1 => { "first_name" => "David" }, 2 => { "first_name" => "Jeremy"} } 写死还是报同样的错误
分享到:
- 2007-07-13 18:45
- 浏览 5497
- 评论(2)
- 论坛回复 / 浏览 (2 / 4127)
- 查看更多
相关推荐
在C:Apache2. … 近在做webservices,得到的数据是从德国那边的服务器。要将这些数据整合到现在网站中去。不知道性能如何。做个压力测试。现在有些压力测试工具都是收费的。在开源的apache中自带个ab工具。在C:...
撬救 Ruby的超快速调试。 (请参阅 ) 介绍 pry-rescue是Ruby的“未处理异常中断”的实现。...ArgumentError : wrong number of arguments ( 2 for 1 ) from /home/conrad / 0 / ruby / pry - rescue / example
解决旧版本2.1.1在编译时的报错/usr/include/nlohmann/json.hpp:6057:62: error: wrong number of template arguments (1, should be 2)
Improved error message for adb push with insufficient number of arguments. fastboot Improved flashing: flashall will now skip reboots to userspace if it can. Fixed zero length packet sends for macOS ...
2)....Fixed: Range check error in processes information for x64 machines (affects startup of any EurekaLog-enabled module) 3)....Fixed: Auto-detect personality by project extension if --el_mode switch...
Other C++ Features Reference Arguments Function Overloading Default Arguments Variable-Length Arrays and alloca() Friends Exceptions Run-Time Type Information (RTTI) Casting Streams Preincrement and ...
// 2001-APR-27 - StreamLoad was calculating the number of BYTES in one // case, not characters. Thanks to Pablo Presedo for this. // // 2001-FEB-23 - Replace() had a bug which caused infinite ...
default: ExitMessage("Wrong number of command line arguments (%d). \n" "Syntax: fw <text user interface file>.", argc-1); } Init(tuiFileName); MainVolume = (my_float*)Alloc_1D(no_links, ...
Mismatched number of parameters in definition ---------------------定义中参数个数不匹配 Misplaced break ---------------------此处不应出现break语句 Misplaced continue ------------------------此处不应...
The XMLHttpRequest and settings used for that request are passed as arguments to the callback. 返回值 jQuery 参数 callback (Function) : 待执行函数 示例 当 AJAX 请求成功后显示消息。 jQuery 代码: ...
PART 2—CORE CONSTRUCTS AND TECHNIQUES OF THE LANGUAGE Chapter 4—Basic constructs and elementary data types.......................................................49 4.1. Filenames—Keywords—...
PART 2—CORE CONSTRUCTS AND TECHNIQUES OF THE LANGUAGE Chapter 4—Basic constructs and elementary data types.......................................................49 4.1. Filenames—Keywords—...