Pergunta

Guys I'm using a select() tag in .html.erb file as follows

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

what's wrong in this statement? actually it is giving an error called

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

But same thing I executed in irb console, it's working fine like

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

using irb console I'm getting correct result

    => [["Gruh", 117]]

but when I put it in .html.erb file, It's giving argument error. How to solve this?

Foi útil?

Solução

Look at this. select method has 3 obligatory parameters and you provide only two..

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top