Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ...
- update: function(){
- $.ajax({
- url: '/groups/order_links',
- ...
- ...
- update: function(){
- $.ajax({
- url: "#{order_links_groups_path}",
- ...
- ...
- url: "#{order_links_groups_url}",
- ...
- ...
- PUT /groups/:group_id/links/:id(.:format) links#update
- DELETE /groups/:group_id/links/:id(.:format) links#destroy
- order_links_groups POST /groups/order_links(.:format) groups#order_links
- groups GET /groups(.:format) groups#index
- POST /groups(.:format) groups#create
- new_group GET /groups/new(.:format) groups#new
- edit_group GET /groups/:id/edit(.:format) groups#edit
- resources :groups do
- resources :links
- collection do
- post 'order_links'
- end
- end
- class GroupsController < ApplicationController
- ...
- def order_links
- params[:link].each_with_index do |id, index|
- Link.where(id: id).update_all(['position = ?',index+1])
- end
- render :nothing => true
- end
- ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement