http://trevmex.com/post/5639010531/building-rails-apps-for-the-rich-client
- https://img.skitch.com/20110519-k3rt6g257tmhnmprpeutcixbnt.png
- https://img.skitch.com/20110519-kf2jaif3byjhpa8w81y9yeahsw.png
- https://github.com/drogus/bulk_api
# GET /api/bulk?posts=all
{
posts: [
{
id: 1,
title: "This is a post"
}
]
}
# GET /api/bulk?posts=1,2
{
posts: [
{
id: 1,
title: "This is a post"
},
{
id: 2,
title: "Another post"
}
]
}
# POST /api/bulk
{
posts: [
{ title: "This is a post" },
{ title: "Another post" }
]
}
# PUT /api/bulk
{
posts: [
{
id: 1,
title: "This is a post"
},
{
id: 2,
title: "Another post"
}
]
}
# POST /api/bulk
{
posts: [
{ title: "This is a post" },
{ title: "Another post" }
]
}
# becomes:
Post.create(title: "This is a post")
Post.create(title: "Another post")
class ApplicationResource < Bulk::Resource
def authenticate(method)
# do devise stufff
end
def authorize(method)
user.admin?
end
end
class PostsResource < Bulk::Resource
delegate :current_user, to: 'controller'
def authorize_record(action, record)
current_user.can?(action, record)
end
def create(hashes)
# custom create code for posts
end
end