Created
July 3, 2014 03:52
-
-
Save cthornton/960aaeabb3d43e768e66 to your computer and use it in GitHub Desktop.
Blog: sample posts controller with to_json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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