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

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是不是过时了。

相关推荐

    压力测试工具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

    Json版本3.11.2

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

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

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

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

    一个跨平台的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 ...

    Frank wolfe

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

    C++出错提示英汉对照表

    Mismatched number of parameters in definition ---------------------定义中参数个数不匹配 Misplaced break ---------------------此处不应出现break语句 Misplaced continue ------------------------此处不应...

    jquery电子文档chm

    The XMLHttpRequest and settings used for that request are passed as arguments to the callback. 返回值 jQuery 参数 callback (Function) : 待执行函数 示例 当 AJAX 请求成功后显示消息。 jQuery 代码: ...

    The way to go

    PART 2—CORE CONSTRUCTS AND TECHNIQUES OF THE LANGUAGE Chapter 4—Basic constructs and elementary data types.......................................................49 4.1. Filenames—Keywords—...

    [Go语言入门(含源码)] The Way to Go (with source code)

    PART 2—CORE CONSTRUCTS AND TECHNIQUES OF THE LANGUAGE Chapter 4—Basic constructs and elementary data types.......................................................49 4.1. Filenames—Keywords—...

Global site tag (gtag.js) - Google Analytics