<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: gravatar for rails app</title>
	<atom:link href="http://scottmotte.com/archives/99/feed" rel="self" type="application/rss+xml" />
	<link>http://scottmotte.com/archives/99</link>
	<description>codes a lot</description>
	<pubDate>Fri, 05 Dec 2008 00:55:00 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: Scott Motte</title>
		<link>http://scottmotte.com/archives/99#comment-174</link>
		<dc:creator>Scott Motte</dc:creator>
		<pubDate>Mon, 21 Jul 2008 02:31:49 +0000</pubDate>
		<guid isPermaLink="false">http://scottmotte.com/?p=99#comment-174</guid>
		<description>Update: The rails cookbook solution just isn't that great. You can't specify a default.

&lt;a href="http://douglasfshearer.com/blog/gravatar-for-ruby-and-ruby-on-rails" rel="nofollow"&gt;Much better solution&lt;/a&gt;


module GravatarHelper
  # Returns a Gravatar URL associated with the email parameter.
  def gravatar_url(email,gravatar_options={})

    # Default highest rating.
    # Rating can be one of G, PG, R X.
    # If set to nil, the Gravatar default of X will be used.
    gravatar_options[:rating] &#124;&#124;= nil

    # Default size of the image.
    # If set to nil, the Gravatar default size of 80px will be used.
    gravatar_options[:size] &#124;&#124;= nil 

    # Default image url to be used when no gravatar is found
    # or when an image exceeds the rating parameter.
    gravatar_options[:default] &#124;&#124;= 'http://localhost:3000/images/gravatar-80.png'

    # Build the Gravatar url.
    grav_url = 'http://www.gravatar.com/avatar.php?'
    grav_url &#60;&#60; "gravatar_id=#{Digest::MD5.new.update(email)}" 
    grav_url &#60;&#60; "&#38;rating=#{gravatar_options[:rating]}" if gravatar_options[:rating]
    grav_url &#60;&#60; "&#38;size=#{gravatar_options[:size]}" if gravatar_options[:size]
    grav_url &#60;&#60; "&#38;default=#{gravatar_options[:default]}" if gravatar_options[:default]
    return grav_url
  end
  
end</description>
		<content:encoded><![CDATA[<p>Update: The rails cookbook solution just isn&#8217;t that great. You can&#8217;t specify a default.</p>
<p><a href="http://douglasfshearer.com/blog/gravatar-for-ruby-and-ruby-on-rails" rel="nofollow">Much better solution</a></p>
<p>module GravatarHelper<br />
  # Returns a Gravatar URL associated with the email parameter.<br />
  def gravatar_url(email,gravatar_options={})</p>
<p>    # Default highest rating.<br />
    # Rating can be one of G, PG, R X.<br />
    # If set to nil, the Gravatar default of X will be used.<br />
    gravatar_options[:rating] ||= nil</p>
<p>    # Default size of the image.<br />
    # If set to nil, the Gravatar default size of 80px will be used.<br />
    gravatar_options[:size] ||= nil </p>
<p>    # Default image url to be used when no gravatar is found<br />
    # or when an image exceeds the rating parameter.<br />
    gravatar_options[:default] ||= &#8216;http://localhost:3000/images/gravatar-80.png&#8217;</p>
<p>    # Build the Gravatar url.<br />
    grav_url = &#8216;http://www.gravatar.com/avatar.php?&#8217;<br />
    grav_url &lt;&lt; &#8220;gravatar_id=#{Digest::MD5.new.update(email)}&#8221;<br />
    grav_url &lt;&lt; &#8220;&amp;rating=#{gravatar_options[:rating]}&#8221; if gravatar_options[:rating]<br />
    grav_url &lt;&lt; &#8220;&amp;size=#{gravatar_options[:size]}&#8221; if gravatar_options[:size]<br />
    grav_url &lt;&lt; &#8220;&amp;default=#{gravatar_options[:default]}&#8221; if gravatar_options[:default]<br />
    return grav_url<br />
  end</p>
<p>end</p>
]]></content:encoded>
	</item>
</channel>
</rss>
