Skip to content

Instantly share code, notes, and snippets.

@harlow
Forked from dhh/gist:981520
Created August 6, 2014 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harlow/a9667ac1309544d32461 to your computer and use it in GitHub Desktop.
Save harlow/a9667ac1309544d32461 to your computer and use it in GitHub Desktop.
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment