Friday, October 21, 2011

[Rails] Re: add an array to params

The problem is that i get all the values in a sibngle field of the
array.
This is the log of the parameters:

Parameters: {"items"=>{"0"=>{"flag"=>"true", "desc"=>"Description",
"value"=>"2"}}, "commit"=>"Create ...

If I try to get the parameters inside the items in this way:

params[:items].each do |i|
logger.debug("--> #{i[:desc]} "); <- row 80
logger.debug("--> #{i[:value]} ");
logger.debug("--> #{i[:flag]} ");
end

I get this error

TypeError (Symbol as array index):
app/controllers/pay_checks_controller.rb:80:in `[]'
app/controllers/pay_checks_controller.rb:80:in `create'
app/controllers/pay_checks_controller.rb:79:in `each'
app/controllers/pay_checks_controller.rb:79:in `create'

But... I can acces with a direct indexing as:
items[0] I get "0"
and items[1] I get flagtruedescDescriptionvalue2

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate