public
Last active — forked from dhh/gist:981520

bulk api

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
# Bulk API design
#
# resources :posts
class PostsController < ActiveController::Base
# GET /posts/1,4,50,90
# post_url([ @post, @post ])
def show_many
@posts = Post.find(params[:ids])
end
 
# PUT /posts/1,4,50,90
def update_many
@posts = Post.find(params[:ids])
 
Post.transaction do
@posts.each do |post|
post.update_attributes!(params[:posts][post.id])
end
end
end
# POST /posts/many
def create_many
end
 
# DELETE /posts/1,4,50,90
def destroy_many
end
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.