Created
September 23, 2012 15:25
-
-
Save MikeSilvis/3772029 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 PhotoSerializer < ActiveModel::Serializer | |
attributes :id, :created_at, :photo_url_thumb, :photo_url_large | |
# Only include these if it is coming from the show action | |
has_many :likes | |
has_many :tags | |
has_many :comments | |
end |
This file contains hidden or 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 PhotosController < ApplicationController | |
def index | |
render json: Photo.all | |
end | |
def show | |
render json: Photo.where(id: params[:id]).includes(:comments, :tags, :likes).first | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment