i hash inside a hash i read it  list[:outer_value][:deeper_value] and you
can do

  list.each do |key,value|
   if value.class == 'Hash'
      puts "values for key #{ key}"
       value.each do | key2,value2|
             puts "key: #{key2} and value: #{value2}"
        end
   else
       puts "key: #{key} and value: #{value}"
   end
  end

2010/9/22 Pål Bergström <[email protected]>

> Greg Willits wrote:
>
> > If you need help with that, give an exampe of the exact data structure
> > you'd be starting with.
> >
>
> With the help of sortable_element and :tree set as true (and moving up
> item 3 before item 1, just as a test) I get a Hash from this list:
>
>
> <ul>
> <li id="3"></li>
> <li id="1"></li>
> <li id="5"><ul><li id="6"></li></ul></li>
> <li id="7"></li>
> </ul>
>
> The hash:
>
> {"0"=>{"id"=>"3"}, "1"=>{"id"=>"1"}, "2"=>{"0"=>{"id"=>"6"}, "id"=>"5",
> "1"=>{"id"=>"7"}}}
>
> I can sort out the key and value. But with key nr 2 I have problem (id 5
> with sub list containing id 6). If I use params[:mylist].each do |k,v| I
> only get the key of 2 and value 5. How do I deal with a nested hash like
> that?
>
> I hope I make sense.
> --
> 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected]<rubyonrails-talk%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to