0

伙计们,我在 .html.erb 文件中使用 select() 标记,如下所示

<%= select(:hfi_id, b.beneficiaryloans.collect { |h| [User.find(h.hfi_id).firstname, h.hfi_id] }) %>

这句话有什么问题?实际上它给出了一个名为

 wrong number of arguments (2 for 3) - error for above line

但是我在 irb 控制台中执行了同样的事情,它工作得很好

irb(main):012:0> me=Beneficiary.find(1)
=> #<Beneficiary id: 1, firstname: "Mohan", lastname: "Bairwa", address: "1399 m.k.b jagatpira", age: 24, sex: "Male", total_members: 1, cso_id: 123, project_id: 17, remarks: nil, status_id: 4, created_at: "2011-11-07 09:39:24", updated_at: "2011-11-07 09:55:07">

irb(main):018:0> me.beneficiaryloans.collect {|h|User.find(h.hfi_id).firstname,h.hfi_id]}
=> [["Gruh", 117]]

使用 irb 控制台我得到了正确的结果

    => [["Gruh", 117]]

但是当我把它放在 .html.erb 文件中时,它给出了参数错误。如何解决这个问题?

4

1 回答 1

1

看看这个select方法有 3 个强制性参数,您只提供两个..

于 2011-11-07T12:15:44.213 回答