Guest User

Untitled

a guest
Apr 26th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. ## view
  2.  
  3. <%= sortable_element 'sortable_list',
  4. :update => 'pages',
  5. :url => update_positions_admin_pages_path,
  6. :handle => 'handle' %>
  7.  
  8. ## controller
  9.  
  10. def update_positions
  11. params["sortable_list"].each_with_index do |id, position|
  12. Page.update(id, :position => position+1)
  13. end
  14. render :nothing => true
  15. end
  16.  
  17. ## routes.rb
  18.  
  19. # Administration
  20. map.namespace :admin do |admin|
  21. ...
  22. admin.resources :pages, :collection => { :update_positions => :put }
  23. ...
  24. end
  25.  
  26. ## development.log (correct routing to admin/pages controller)
  27.  
  28. Processing PagesController#update_positions (for 127.0.0.1 at 2008-05-14 11:50:23) [POST]
  29. Session ID: BAh7CToOcmV0dXJuX3RvMDoMY3NyZl9pZCIlNDJiODgxNGNlNTU5MmM2MmRh%0AY2Y0OTBlNjM2OWNjODYiCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZs%0AYXNoOjpGbGFzaEhhc2h7AAY6CkB1c2VkewA6DHVzZXJfaWRpBg%3D%3D--4029be28db1c3f53d6deae3f0ecdf3e0ecec3440
  30. Parameters: {"authenticity_token"=>"62c50cd2d3ae08a518c85e17850111aad0965c36", "action"=>"update_positions", "sortable_list"=>["1", "2", "3", "6", "4", "5"], "controller"=>"admin/pages"}
  31.  
  32. ## production.log (incorrect routing to admin/pages as an ACTION)
  33.  
  34. Processing AdminController#pages (for 98.173.215.130 at 2008-05-14 13:51:19) [POST]
  35. Session ID: BAh7CToMY3NyZl9pZCIlMDc2Y2NhOGU4MTFiZDhjNzkzNWNiNzk2NzNjNzlm%0AYTM6DHVzZXJfaWRpBjoOcmV0dXJuX3RvMCIKZmxhc2hJQzonQWN0aW9uQ29u%0AdHJvbGxlcjo6Rmxhc2g6OkZsYXNoSGFzaHsABjoKQHVzZWR7AA%3D%3D--3d93637c4d089c3d28744b853831a78e7e9775a9
  36. Parameters: {"authenticity_token"=>"736ff9291c0421cf0ace7fe2cf65607b08353364", "action"=>"pages", "sortable_list"=>["1", "7", "3", "2", "4", "5", "6"], "id"=>"update_positions", "controller"=>"admin"}
Add Comment
Please, Sign In to add comment