`
jackdraw
  • 浏览: 56099 次
  • 来自: ...
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

wrong number of arguments (2 for 0) 错误

阅读更多

今天在想着怎么样来批量修改

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"} }  写死还是报同样的错误

分享到:
评论
2 楼 jackdraw 2007-07-19  
应该不会是这个问题,因为我拿到的是最新的,基本上可以用,不过现在我已经解决了这个问题, 不过我的处理方式是在form中做了文章,而不是转换,我想这种参数{"id" => "df",name=>"dfd"}结构更符合人的思想行为一些,我想上面那个问题上,应该是在转换的时候数据类型产生了变动,或是其他原因
1 楼 yawl 2007-07-19  
error msg的意思是update method不接受任何参数, 你得看看那段comment里的example是不是过时了。

相关推荐

    用golang实现的一个轻量级noSQL数据库,支持redis命令的一个常用小子集.zip

    2. **部分Redis命令支持**:Gedis可能只实现了Redis命令的一部分,例如SET、GET、LPUSH、RPOP等基础命令,以满足常见操作需求。 3. **简单的API设计**:Gedis的API设计可能会尽可能接近Redis,让熟悉Redis的开发者...

    wdaproxy 启动就退出,报exit status 234 错误码。

    当尝试启动wdaproxy时,它会立即退出并返回exit status 234错误码,这通常是由于某些配置或兼容性问题导致的。 标题中提到的问题是“wdaproxy启动就退出,报exit status 234错误码”。这个错误码并不是标准的Unix...

    压力测试工具apache-ab讲解

    在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

    platform-tools-r34.0.0-windows.zip.7z

    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 ...

    Json版本3.11.2

    解决旧版本2.1.1在编译时的报错/usr/include/nlohmann/json.hpp:6057:62: error: wrong number of template arguments (1, should be 2)

    Javascript中arguments和arguments.callee的区别浅析

    在示例中,由于 `f(1,2)` 只传递了2个参数,而 `f` 函数定义时需要3个参数(x, y, z),所以输出 "wrong number of arguments",表明参数数量不匹配。 需要注意的是,`arguments.callee` 在 ES5 严格模式下被禁用,...

    Matlab简单语法.ppt

    `nargin` 用于检查函数输入参数的数量,`error` 语句可以在参数数量不正确时抛出错误,如 `if nargin ~= 2, error('Wrong number of input arguments') end`。 - 循环语句如 `for` 和 `while` 用于重复执行代码块,...

    EurekaLog_7.5.0.0_Enterprise

    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...

    MATLAB自定义函数及局部变量 (2).docx

    error('Wrong number of input arguments.'); end A1=zeros(n,m); for i=1: n for j=1:m A1(i,j)=1/(i+j-1); end end if nargout==1, A=A1; elseif nargout==0, disp(A1); end ``` 这个函数可以生成 Hilbert ...

    oracle存储过程调用实践[文].pdf

    3. wrong number or types of arguments in call to *** 当调用存储过程时,传递的参数数量或类型与存储过程定义的不符,需要核对参数列表,确保传入的参数正确无误。 4. weblogic.jdbc.wrapper.Array_oracle_sql_...

    freemarker自学笔记

    throw new TemplateModelException("Wrong number of arguments"); } return new SimpleNumber(((String) arguments.get(1)).indexOf((String) arguments.get(0))); } } ``` 在这个例子中,`IndexOfMethod` 类...

    PB调用存储

    例如,在上面的例子中,我们遇到了“wrong number or type of arguments in calling insurance.updatemedinfo line 1 column 15”的错误。 这个错误的原因可能是因为存储过程的参数数量或类型与调用存储过程时传递...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    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 ...

    解决python gdal投影坐标系转换的问题

    在使用Python的GDAL库进行坐标系转换时,如果遇到错误提示"NotImplementedError: Wrong number or type of arguments for overloaded function 'CoordinateTransformation_TransformPoint'",则很可能是由于输入参数...

    一个跨平台的CString源码

    // 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 ...

    MATLAB实现灰色预测程序

    error('Wrong number of input arguments.'); end x_orig = X; % 对原始数据进行AGO处理 x = cumsum(x_orig); % 构建系数矩阵B n = length(x_orig); B = zeros(n - 1, 2); for i = 1:(n - 1) B(i, :) = [-(x(i)...

    如何在Windows下开发NodeJS的C/C++原生扩展

    ThrowException(Exception::TypeError(String::New("Wrong number of arguments"))); return scope.Close(Undefined()); } if (!args[0]->IsNumber()) { ThrowException(Exception::TypeError(String::New(...

    foxmail常见问题解决方案

    9. Wrong number of command arguments。 解决方案:使用收发邮件检测工具自动定位问题,排查计算机网络环境、代理设置、杀毒软件设置等原因,并检查服务器、端口和SSL安全连接是否正确设置。 10. Parse error: ...

    灰色预测代码

    error('Wrong number of input arguments.'); end ``` #### 灰色预测模型实现 1. **累积生成**(Cumulative Generating Operation):对原始数据进行累加处理,得到新的序列`x`。 2. **构建背景值**:根据累加...

Global site tag (gtag.js) - Google Analytics