Created
April 16, 2014 20:52
-
-
Save xrl/10931891 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 AdsSerializer < ActiveModel::Serializer | |
attributes :target_url, | |
:image_url, | |
:thumb_url | |
def image_url | |
image.url | |
end | |
def thumb_url | |
thumb.url | |
end | |
end | |
class AndroidAdSerializer < AdsSerializer | |
attributes :something_custom | |
end | |
# in the controller | |
if @i_know_its_android | |
render json: @ad, serializer: AndroidAdSerializer | |
else | |
render json: @ad | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment