Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAshkan Neshagaran
29,205 PointsBuild a Simple Ruby on Rails Application Gravatar Help
Hi. I was working on this code challenge and was completely stumped on the final step. This is the video : http://teamtreehouse.com/library/build-a-simple-ruby-on-rails-application/deploying/adding-gravatars-2 and this is what it is asking : Update the gravatar_url method so it returns gravatr url, which takes the form http://gravatar.com/avatar/HASH where HASH is the hash you have just computed
This is what I put but it is not working. Please help.
class User < ActiveRecord::Base def gravatar_url self.email return http://gravatar.com/avatar/Digest::MD5.hexdigest(email.strip.downcase.strip) end end
3 Answers
Alyssa Gowan
46,260 PointsI think you are missing a few lines. I passed with:
class User < ActiveRecord::Base
def gravatar_url
self.email
email.downcase.strip
hash = Digest::MD5.hexdigest(email.downcase.strip)
return "http://gravatar.com/avatar/#{hash}"
end
end
Sorry about the comment above; I didn't mean to post it twice... Maybe its easier to read here.
Alyssa Gowan
46,260 PointsHi Ashkan! I struggled with this one myself :)
I think you simply overthought it. Instead of writing out the entire hash sequence in the url, you only have to put:
"http://gravatar.com/avatar/#{hash}"
For an explanation, rewatch the video starting at about 8:30.
Alyssa
Ashkan Neshagaran
29,205 PointsSorry for bothering you again but when I tried, it didn't seem to work. I'm not sure what I'm doing wrong. class User < ActiveRecord::Base def gravatar_url self.email return http://gravatar.com/avatar/#{hash} end end
Alyssa Gowan
46,260 PointsIt looks like you are missing a few lines. Here is what I passed with:
class User < ActiveRecord::Base
def gravatar_url
self.email
email.downcase.strip
hash = Digest::MD5.hexdigest(email.downcase.strip)
return "http://gravatar.com/avatar/#{hash}"
end
end
Ashkan Neshagaran
29,205 PointsThanks Alyssa. I appreciate it.
Yoochan Seo
305 PointsYoochan Seo
305 PointsSimply the below works.