Created
May 15, 2018 15:16
-
-
Save gregblake/81109b0611c8f7a1b372b95c7135c5ed to your computer and use it in GitHub Desktop.
Rendering json for Project photos that may or may not be associated with a media_item
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
| def show | |
| project_photo = ProjectPhoto.find(params[:id]) | |
| if project_photo.media_item? | |
| media_item = # Some method to lookup the media_item associated with the project_photo | |
| render json: media_item.as_json | |
| else | |
| # You have at least 2 options here. You could: | |
| # 1) refactor the project_photo Boxer representation into a similar as_json method, or | |
| # 2) Modify the existing project_photo Boxer representation, and render the json using Boxer. | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment