Hi I am seeing some corruption of a hash that I create in a .rhtml and then pass in :params back to an action. In the .rhtml I do :- <% @pp = { "t" => {"todo_id" => todo.id, "position" => todo.position}} %> <td><%= link_to_image "note", :action => "list_edit", :id => todo.id, :params => @pp %></td> <td><%= debug @pp %></td> The debug YAML looks OK:- t: todo_id: 23 position: 2 However the hash is corrupted when the list_edit action is executed :- render_text @params.inspect {"action"=>"list_edit", "id"=>"23", "controller"=>"todos", "t"=>"todo_id23position2"} I would expect:- {"action"=>"list_edit", "id"=>"23", "controller"=>"todos", "t"=>{"todo_id"=>"23", "position"=>"2"}} (The @pp tmp var is so that I can debug. It doesn''t change the result) Thanks for any help Peter
On Apr 5, 2005 9:51 PM, Cutting Peter <Peter.Cutting-CwpgxV1jTAxWk0Htik3J/w@public.gmane.org> wrote:> Hi > I am seeing some corruption of a hash that I create in a .rhtml and then > pass in :params back to an action. In the .rhtml I do :- > > <% @pp = { "t" => {"todo_id" => todo.id, "position" => todo.position}} > %> > <td><%= link_to_image "note", :action => "list_edit", :id => todo.id, > :params => @pp %></td> > <td><%= debug @pp %></td> > > The debug YAML looks OK:- > t: > todo_id: 23 > position: 2 > > However the hash is corrupted when the list_edit action is executed :- > render_text @params.inspect > > {"action"=>"list_edit", "id"=>"23", "controller"=>"todos", > "t"=>"todo_id23position2"} > > I would expect:- > {"action"=>"list_edit", "id"=>"23", "controller"=>"todos", > "t"=>{"todo_id"=>"23", "position"=>"2"}} > > (The @pp tmp var is so that I can debug. It doesn''t change the result)try passing @pp.dup to link_to_image and see what happens. -- Phillip Hutchings http://www.sitharus.com/ sitharus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org / sitharus-QrR4M9swfipWk0Htik3J/w@public.gmane.org
Hi Trying the following did not help>>try passing <at> pp.dup to link_to_image and see what happens.No change Peter -----Original Message----- From: Cutting Peter Sent: Tuesday, April 05, 2005 11:52 AM To: ''rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org'' Subject: Stuck on a hash problem Hi I am seeing some corruption of a hash that I create in a .rhtml and then pass in :params back to an action. In the .rhtml I do :- <% @pp = { "t" => {"todo_id" => todo.id, "position" => todo.position}} %> <td><%= link_to_image "note", :action => "list_edit", :id => todo.id, :params => @pp %></td> <td><%= debug @pp %></td> The debug YAML looks OK:- t: todo_id: 23 position: 2 However the hash is corrupted when the list_edit action is executed :- render_text @params.inspect {"action"=>"list_edit", "id"=>"23", "controller"=>"todos", "t"=>"todo_id23position2"} I would expect:- {"action"=>"list_edit", "id"=>"23", "controller"=>"todos", "t"=>{"todo_id"=>"23", "position"=>"2"}} (The @pp tmp var is so that I can debug. It doesn''t change the result) Thanks for any help Peter
> Hi > I am seeing some corruption of a hash that I create in a .rhtml and then > pass in :params back to an action. In the .rhtml I do :- > > <% @pp = { "t" => {"todo_id" => todo.id, "position" => todo.position}} > %> > <td><%= link_to_image "note", :action => "list_edit", :id => todo.id, > :params => @pp %></td> > <td><%= debug @pp %></td> > > The debug YAML looks OK:- > t: > todo_id: 23 > position: 2 > > However the hash is corrupted when the list_edit action is executed :- > render_text @params.inspect > > {"action"=>"list_edit", "id"=>"23", "controller"=>"todos", > "t"=>"todo_id23position2"} > > I would expect:- > {"action"=>"list_edit", "id"=>"23", "controller"=>"todos", > "t"=>{"todo_id"=>"23", "position"=>"2"}} > > (The @pp tmp var is so that I can debug. It doesn''t change the result)Actually, I think I see your problem. To the best of my knowledge Ruby doesn''t support serialising hashes through URLs, at least not automatically. Try marshalling it in to a string and then unmarshalling it. I don''t know how to do that, but it''s all in the Ruby manual. -- Phillip Hutchings http://www.sitharus.com/ sitharus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org / sitharus-QrR4M9swfipWk0Htik3J/w@public.gmane.org