Created
September 14, 2011 08:27
-
-
Save istvanp/1216104 to your computer and use it in GitHub Desktop.
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
{ | |
city: "Montreal", | |
first_name: "Istvan", | |
id: 1, | |
last_name: "Pusztai", | |
state: "Quebec", | |
avatar_url: "https://secure.gravatar.com/avatar/44c6f8371be4ee1612256855a3e35d12.png?s=48&d=http%3A%2F%2Frobohash.org%2F44c6f8371be4ee1612256855a3e35d12.png%3Fsize%3D48x48%26bgset%3Dany" | |
} |
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
def as_json(options = {}) | |
super only: [ | |
:id, | |
:first_name, | |
:last_name, | |
:full_name, | |
:city, | |
:state | |
], methods: [ | |
:avatar_url | |
] | |
end | |
def avatar_url(size = 48) | |
hash = Digest::MD5.hexdigest(self.email.downcase) | |
default = ERB::Util.u "http://robohash.org/#{hash}.png?size=#{size}x#{size}&bgset=any" | |
"https://secure.gravatar.com/avatar/#{hash}.png?s=#{size}&d=#{default}" | |
end |
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
def show | |
@user = current_user | |
respond_to do | format | | |
format.html | |
format.json { render json: @user } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment