Advertisement
Guest User

Untitled

a guest
Aug 30th, 2014
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. ...
  2. update: function(){
  3. $.ajax({
  4. url: '/groups/order_links',
  5. ...
  6.  
  7. ...
  8. update: function(){
  9. $.ajax({
  10. url: "#{order_links_groups_path}",
  11. ...
  12.  
  13. ...
  14. url: "#{order_links_groups_url}",
  15. ...
  16.  
  17. ...
  18. PUT /groups/:group_id/links/:id(.:format) links#update
  19. DELETE /groups/:group_id/links/:id(.:format) links#destroy
  20. order_links_groups POST /groups/order_links(.:format) groups#order_links
  21. groups GET /groups(.:format) groups#index
  22. POST /groups(.:format) groups#create
  23. new_group GET /groups/new(.:format) groups#new
  24. edit_group GET /groups/:id/edit(.:format) groups#edit
  25.  
  26. resources :groups do
  27. resources :links
  28. collection do
  29. post 'order_links'
  30. end
  31. end
  32.  
  33. class GroupsController < ApplicationController
  34.  
  35. ...
  36. def order_links
  37. params[:link].each_with_index do |id, index|
  38. Link.where(id: id).update_all(['position = ?',index+1])
  39. end
  40. render :nothing => true
  41. end
  42. ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement