Skip to content

Instantly share code, notes, and snippets.

@cthornton
Created July 3, 2014 03:52
Show Gist options
  • Save cthornton/960aaeabb3d43e768e66 to your computer and use it in GitHub Desktop.
Save cthornton/960aaeabb3d43e768e66 to your computer and use it in GitHub Desktop.
Blog: sample posts controller with to_json
class PostsController < ApiController
def index
@posts = current_user.posts
render json: @posts.to_json(only: [:id, :title, :description]})
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment