Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## view
- <%= sortable_element 'sortable_list',
- :update => 'pages',
- :url => update_positions_admin_pages_path,
- :handle => 'handle' %>
- ## controller
- def update_positions
- params["sortable_list"].each_with_index do |id, position|
- Page.update(id, :position => position+1)
- end
- render :nothing => true
- end
- ## routes.rb
- # Administration
- map.namespace :admin do |admin|
- ...
- admin.resources :pages, :collection => { :update_positions => :put }
- ...
- end
- ## development.log (correct routing to admin/pages controller)
- Processing PagesController#update_positions (for 127.0.0.1 at 2008-05-14 11:50:23) [POST]
- Session ID: BAh7CToOcmV0dXJuX3RvMDoMY3NyZl9pZCIlNDJiODgxNGNlNTU5MmM2MmRh%0AY2Y0OTBlNjM2OWNjODYiCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZs%0AYXNoOjpGbGFzaEhhc2h7AAY6CkB1c2VkewA6DHVzZXJfaWRpBg%3D%3D--4029be28db1c3f53d6deae3f0ecdf3e0ecec3440
- Parameters: {"authenticity_token"=>"62c50cd2d3ae08a518c85e17850111aad0965c36", "action"=>"update_positions", "sortable_list"=>["1", "2", "3", "6", "4", "5"], "controller"=>"admin/pages"}
- ## production.log (incorrect routing to admin/pages as an ACTION)
- Processing AdminController#pages (for 98.173.215.130 at 2008-05-14 13:51:19) [POST]
- Session ID: BAh7CToMY3NyZl9pZCIlMDc2Y2NhOGU4MTFiZDhjNzkzNWNiNzk2NzNjNzlm%0AYTM6DHVzZXJfaWRpBjoOcmV0dXJuX3RvMCIKZmxhc2hJQzonQWN0aW9uQ29u%0AdHJvbGxlcjo6Rmxhc2g6OkZsYXNoSGFzaHsABjoKQHVzZWR7AA%3D%3D--3d93637c4d089c3d28744b853831a78e7e9775a9
- 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