Guest User

Untitled

a guest
Jul 18th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. def forming_position
  2. nodes = params[:nodes_list].permit!
  3. nodes.each do |node|
  4. recursive_sorting node
  5. end
  6. end
  7.  
  8. def recursive_sorting(node, parent = nil)
  9. position = node[0]
  10. value = node[1]
  11. ......
  12. end
  13.  
  14. params[:nodes_list]
  15. => <ActionController::Parameters {"1"=><ActionController::Parameters {"id"=>"3"} permitted: true>, "2"=><ActionController::Parameters {"id"=>"2"} permitted: true>, "3"=><ActionController::Parameters {"id"=>"1"} permitted: true>} permitted: true>
  16.  
  17. nodes
  18. => <ActionController::Parameters {"1"=><ActionController::Parameters {"id"=>"3"} permitted: true>, "2"=><ActionController::Parameters {"id"=>"2"} permitted: true>, "3"=><ActionController::Parameters {"id"=>"1"} permitted: true>} permitted: true>
  19. nodes == params[:nodes_list]
  20. => true
  21.  
  22. node
  23. => "1"
  24.  
  25. nodes.first
  26. => ["1", <ActionController::Parameters {"id"=>"3"} permitted: true>]
Add Comment
Please, Sign In to add comment