<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Amit Yadav &#187; Ruby</title>
	<atom:link href="http://www.amityadav.name/tag/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.amityadav.name</link>
	<description>Things to know for effective coding</description>
	<lastBuildDate>Fri, 19 Aug 2011 17:51:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Fast-track your Web apps with Ruby on Rails</title>
		<link>http://www.amityadav.name/fast-track-your-web-apps-with-ruby-on-rails/</link>
		<comments>http://www.amityadav.name/fast-track-your-web-apps-with-ruby-on-rails/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 03:29:23 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[ror]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/?p=809</guid>
		<description><![CDATA[Fast-track your Web apps with Ruby on Rails Ruby on Rails is a recent entry into the world of Web application development that is rapidly gaining mindshare, even while still in beta versions. Rails succeeds by automating the creation of the most common types of Web applications while not straightjacketing you if you want to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ibm.com/developerworks/opensource/library/l-rubyrails/index.html" target="_blank"><strong>Fast-track your Web apps with Ruby on Rails</strong></a></p>
<div id="">Ruby on Rails is a recent entry into the world of Web application development that is rapidly gaining mindshare, even while still in beta versions. Rails succeeds by automating the creation of the most common types of Web applications while not straightjacketing you if you want to add custom or atypical requirements. Moreover, compared to many Free Software libraries that perform individual aspects of a Web application, Rails contains a nicely integrated set of tools for all aspects.</div>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Ffast-track-your-web-apps-with-ruby-on-rails%2F&amp;title=Fast-track%20your%20Web%20apps%20with%20Ruby%20on%20Rails" id="wpa2a_2"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/fast-track-your-web-apps-with-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Difference between delete and destroy in ActiveRecord</title>
		<link>http://www.amityadav.name/difference-between-delete-and-destroy-in-activerecord/</link>
		<comments>http://www.amityadav.name/difference-between-delete-and-destroy-in-activerecord/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 03:26:20 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[ror]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/?p=805</guid>
		<description><![CDATA[To delete a particular record we will go for delete or destroy methods.But according to the names both looks very similar, but the functionality wise both are different. so lets check the difference between delete and destroy methods in Active Record. Now first check what the delete method will do: Delete method deletes the row [...]]]></description>
			<content:encoded><![CDATA[<p><span class="postbody">To delete a particular record we will go for delete or destroy methods.But according to the names both looks very similar, but the functionality wise both are different. so lets check the difference between delete and destroy methods in Active Record. </span></p>
<p>Now first check what the delete method will do:</p>
<p>Delete method deletes the row with a primary key matching the id argument, using a SQL DELETE statement, and returns the number of rows deleted. Active Record objects are not instantiated, so the object&lsquo;s callbacks are not executed, including any :dependent association options or Observer methods.</p>
<p>You can delete multiple rows at once by passing an Array of ids.</p>
<p>It is much faster than the destroy method, skipping callbacks might bypass business logic in your application that makes the function to work fast.</p>
<p><strong>example:</strong> <br />
	Delete a single row <br />
	user.delete(1)</p>
<p>Delete multiple rows <br />
	user.delete([2,3,4])</p>
<p><u><strong>Destroy method: </strong></u><br />
	The destroy method makes the SQL call to the database and destroys the row in the table that contains it. It does still allow you to manipulate the object in the application as long as it&rsquo;s still in scope (i.e) the callbacks and <br />
	filters are allowed even after destroying the object.</p>
<p><strong>example :</strong> <br />
	Destroy a single object <br />
	User.destroy(1)</p>
<p>Destroy multiple objects <br />
	users= [1,2,3] <br />
	User.destroy(users) </p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Fdifference-between-delete-and-destroy-in-activerecord%2F&amp;title=Difference%20between%20delete%20and%20destroy%20in%20ActiveRecord" id="wpa2a_4"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/difference-between-delete-and-destroy-in-activerecord/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mutable and Immutable Objects</title>
		<link>http://www.amityadav.name/mutable-and-immutable-objects/</link>
		<comments>http://www.amityadav.name/mutable-and-immutable-objects/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 03:23:43 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[mutable]]></category>
		<category><![CDATA[non-mutable]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[ror]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/?p=801</guid>
		<description><![CDATA[Mutable objects : 1)Mutable objects are objects whose state can change. 2)In Ruby, Mutability is a property of an instance. 3)Any instance can become immutable by calling the &#34;freeze&#34;. Immutable objects : 1)Immutable objects are objects whose state never changes after creation. 2)Immutable objects are thread-safe(A piece of code is called as thread-safe ,if it [...]]]></description>
			<content:encoded><![CDATA[<p><span class="postbody"><u><strong>Mutable objects : </strong></u><br />
	1)Mutable objects are objects whose state can change. <br />
	2)In Ruby, Mutability is a property of an instance. <br />
	3)Any instance can become immutable by calling the &quot;freeze&quot;. </span></p>
<p><u><strong>Immutable objects : </strong></u><br />
	1)Immutable objects are objects whose state never changes after creation.</p>
<p>2)Immutable objects are thread-safe(A piece of code is called as thread-safe ,if it functions correctly during simultaneous execution by multiple threads).</p>
<p><u><em>Freezing Objects: </em></u><br />
	1:The freeze method in class Object prevents you from changing an object, effectively turning an object into a constant. <br />
	2:After we freeze an object, an attempt to modify the freezed object, results in TypeError. <br />
	3: freeze operates on an object reference, not on a variable. <br />
	4:This means that any operation resulting in a new object.</p>
<p>Example: <br />
	str = &#39;A simple string. &#39; <br />
	str.freeze <br />
	begin <br />
	str &lt;&lt; &#39;An attempt to modify.&#39; <br />
	rescue =&gt; err <br />
	puts &quot;#{err.class} #{err}&quot; <br />
	end</p>
<p># The output is &#8211; TypeError can&#39;t modify frozen string</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Fmutable-and-immutable-objects%2F&amp;title=Mutable%20and%20Immutable%20Objects" id="wpa2a_6"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/mutable-and-immutable-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FFMPEG get video file duration: Ruby</title>
		<link>http://www.amityadav.name/ffmpeg-get-video-file-duration-ruby/</link>
		<comments>http://www.amityadav.name/ffmpeg-get-video-file-duration-ruby/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 09:51:58 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[ffmpeg]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/?p=228</guid>
		<description><![CDATA[  ?View Code RUBY1 2 3 4 5 6 7 8 9 10 11 12 13 14 def get_video_file_duration&#40;inputFilename&#41; command = &#34;ffmpeg -i &#34; + inputFilename.to_s + &#34; 2&#62;&#38;amp;1 &#124; grep 'Duration' &#124; cut -d ' ' -f 4 &#124; sed s/,//&#34; output = `#{command}` &#160; if output =~ /&#40;&#91;\d&#93;&#91;\d&#93;&#41;:&#40;&#91;\d&#93;&#91;\d&#93;&#41;:&#40;&#91;\d&#93;&#91;\d&#93;&#41;.&#40;&#91;\d&#93;+&#41;/ duration = &#40;&#40;$1.to_i * 60 [...]]]></description>
			<content:encoded><![CDATA[<p> </p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p228code2'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2282"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p228code2"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> get_video_file_duration<span style="color:#006600; font-weight:bold;">&#40;</span>inputFilename<span style="color:#006600; font-weight:bold;">&#41;</span>
            command = <span style="color:#996600;">&quot;ffmpeg -i &quot;</span>
                             <span style="color:#006600; font-weight:bold;">+</span> inputFilename.<span style="color:#9900CC;">to_s</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">&quot; 
                             2&gt;&amp;amp;1 | grep 'Duration' 
                             | cut -d ' ' -f 4 | sed s/,//&quot;</span>
                             output = <span style="color:#996600;">`#{command}`</span>
&nbsp;
          <span style="color:#9966CC; font-weight:bold;">if</span> output =~ <span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span>\d<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>\d<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>:<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span>\d<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>\d<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>:<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span>\d<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>\d<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span>\d<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">/</span>
               duration = <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span>$<span style="color:#006666;">1</span>.<span style="color:#9900CC;">to_i</span> <span style="color:#006600; font-weight:bold;">*</span> <span style="color:#006666;">60</span> <span style="color:#006600; font-weight:bold;">+</span> $<span style="color:#006666;">2</span>.<span style="color:#9900CC;">to_i</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">*</span> <span style="color:#006666;">60</span> <span style="color:#006600; font-weight:bold;">+</span> $<span style="color:#006666;">3</span>.<span style="color:#9900CC;">to_i</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">*</span> <span style="color:#006666;">10</span> <span style="color:#006600; font-weight:bold;">+</span> $<span style="color:#006666;">4</span>.<span style="color:#9900CC;">to_i</span>
          <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
          <span style="color:#008000; font-style:italic;">#return duration.to_s</span>
          <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#996600;">&quot;#{$2}:#{$3}&quot;</span>
 <span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p> </p>
<div class="zemanta-pixie" style="margin-top:10px;height:15px"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=f71479c7-4c3a-4dbb-971a-19dcf2453b6c" style="border:none;float:right"><span class="zem-script more-related"><script type="text/javascript" src="http://static.zemanta.com/readside/loader.js" defer="defer"></script></span></div>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Fffmpeg-get-video-file-duration-ruby%2F&amp;title=FFMPEG%20get%20video%20file%20duration%3A%20Ruby" id="wpa2a_8"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/ffmpeg-get-video-file-duration-ruby/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>My Google Knol articles</title>
		<link>http://www.amityadav.name/my-google-knol-articles/</link>
		<comments>http://www.amityadav.name/my-google-knol-articles/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 05:17:14 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[google knol]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/?p=215</guid>
		<description><![CDATA[Ruby on Rails implementation of OpenId Ruby on Rails implementation for Paypal &#124; Download Code Ruby on Rails implementation for Authorize.net]]></description>
			<content:encoded><![CDATA[<p><a title="Ruby on Rails implementation of OpenId" href="http://knol.google.com/k/amit-yadav/ruby-on-rails-implementation-of-openid/u73tenkicdbm/6#" target="_blank">Ruby on Rails implementation of OpenId</a></p>
<p><a title="Ruby on Rails implementation for Paypal" href="http://knol.google.com/k/amit-yadav/ruby-on-rails-implementation-for-paypal/u73tenkicdbm/3" target="_blank">Ruby on Rails implementation for Paypal</a> | <a href="/payment_gateway.rar">Download Code</a></p>
<p><a title="Ruby on Rails implementation for Authorize.net" href="http://knol.google.com/k/amit-yadav/ruby-on-rails-implementation-for/u73tenkicdbm/4" target="_blank">Ruby on Rails implementation for Authorize.net</a></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Fmy-google-knol-articles%2F&amp;title=My%20Google%20Knol%20articles" id="wpa2a_10"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/my-google-knol-articles/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Compile &amp; install Nginx web server</title>
		<link>http://www.amityadav.name/compile-install-nginx-web-server/</link>
		<comments>http://www.amityadav.name/compile-install-nginx-web-server/#comments</comments>
		<pubDate>Mon, 23 Jun 2008 05:25:42 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/compile-install-nginx-web-server/</guid>
		<description><![CDATA[?View Code RUBY1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 # See: # - http://en.wikipedia.org/wiki/Nginx # - http://wiki.codemongers.com/NginxGettingStarted # [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p53code4'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p534"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
</pre></td><td class="code" id="p53code4"><pre class="ruby" style="font-family:monospace;"> <span style="color:#008000; font-style:italic;"># See:</span>
<span style="color:#008000; font-style:italic;"># - http://en.wikipedia.org/wiki/Nginx</span>
<span style="color:#008000; font-style:italic;"># - http://wiki.codemongers.com/NginxGettingStarted</span>
<span style="color:#008000; font-style:italic;"># - http://wiki.codemongers.com/NginxInstallOptions</span>
<span style="color:#008000; font-style:italic;"># - http://wiki.codemongers.com/NginxCommandLine</span>
<span style="color:#008000; font-style:italic;"># - http://wiki.codemongers.com/NginxConfiguration</span>
&nbsp;
export PATH=<span style="color:#996600;">&quot;/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin&quot;</span>
&nbsp;
mkdir <span style="color:#006600; font-weight:bold;">-</span><span style="color:#CC0066; font-weight:bold;">p</span> ~<span style="color:#006600; font-weight:bold;">/</span>Desktop<span style="color:#006600; font-weight:bold;">/</span>Nginx
cd ~<span style="color:#006600; font-weight:bold;">/</span>Desktop<span style="color:#006600; font-weight:bold;">/</span>Nginx
&nbsp;
curl <span style="color:#006600; font-weight:bold;">-</span>L <span style="color:#006600; font-weight:bold;">-</span>O http:<span style="color:#006600; font-weight:bold;">//</span>sysoev.<span style="color:#9900CC;">ru</span><span style="color:#006600; font-weight:bold;">/</span>nginx<span style="color:#006600; font-weight:bold;">/</span>nginx<span style="color:#006600; font-weight:bold;">-</span>0.7.2.<span style="color:#9900CC;">tar</span>.<span style="color:#9900CC;">gz</span>
tar <span style="color:#006600; font-weight:bold;">-</span>xzf nginx<span style="color:#006600; font-weight:bold;">-</span>0.7.2.<span style="color:#9900CC;">tar</span>.<span style="color:#9900CC;">gz</span>
&nbsp;
curl <span style="color:#006600; font-weight:bold;">-</span>L <span style="color:#006600; font-weight:bold;">-</span>O http:<span style="color:#006600; font-weight:bold;">//</span>downloads.<span style="color:#9900CC;">sourceforge</span>.<span style="color:#9900CC;">net</span><span style="color:#006600; font-weight:bold;">/</span>pcre<span style="color:#006600; font-weight:bold;">/</span>pcre<span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">7.7</span>.<span style="color:#9900CC;">tar</span>.<span style="color:#9900CC;">gz</span>
tar <span style="color:#006600; font-weight:bold;">-</span>xzf pcre<span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">7.7</span>.<span style="color:#9900CC;">tar</span>.<span style="color:#9900CC;">gz</span>
&nbsp;
cd ~<span style="color:#006600; font-weight:bold;">/</span>Desktop<span style="color:#006600; font-weight:bold;">/</span>Nginx<span style="color:#006600; font-weight:bold;">/</span>nginx<span style="color:#006600; font-weight:bold;">-</span>0.7.2
.<span style="color:#006600; font-weight:bold;">/</span>configure <span style="color:#006600; font-weight:bold;">--</span>help
.<span style="color:#006600; font-weight:bold;">/</span>configure <span style="color:#006600; font-weight:bold;">--</span>prefix=<span style="color:#006600; font-weight:bold;">/</span>usr<span style="color:#006600; font-weight:bold;">/</span>local<span style="color:#006600; font-weight:bold;">/</span>nginx <span style="color:#006600; font-weight:bold;">--</span>sbin<span style="color:#006600; font-weight:bold;">-</span>path=<span style="color:#006600; font-weight:bold;">/</span>usr<span style="color:#006600; font-weight:bold;">/</span>local<span style="color:#006600; font-weight:bold;">/</span>sbin <span style="color:#006600; font-weight:bold;">--</span>with<span style="color:#006600; font-weight:bold;">-</span>debug <span style="color:#006600; font-weight:bold;">--</span>with<span style="color:#006600; font-weight:bold;">-</span>http_ssl_module <span style="color:#006600; font-weight:bold;">--</span>with<span style="color:#006600; font-weight:bold;">-</span>pcre=..<span style="color:#006600; font-weight:bold;">/</span>pcre<span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">7.7</span>
make
sudo make install
&nbsp;
which nginx
otool <span style="color:#006600; font-weight:bold;">-</span>L <span style="color:#006600; font-weight:bold;">/</span>usr<span style="color:#006600; font-weight:bold;">/</span>local<span style="color:#006600; font-weight:bold;">/</span>sbin<span style="color:#006600; font-weight:bold;">/</span>nginx
<span style="color:#CC0066; font-weight:bold;">open</span> <span style="color:#006600; font-weight:bold;">/</span>usr<span style="color:#006600; font-weight:bold;">/</span>local<span style="color:#006600; font-weight:bold;">/</span>nginx
<span style="color:#CC0066; font-weight:bold;">open</span> <span style="color:#006600; font-weight:bold;">-</span>e <span style="color:#006600; font-weight:bold;">/</span>usr<span style="color:#006600; font-weight:bold;">/</span>local<span style="color:#006600; font-weight:bold;">/</span>nginx<span style="color:#006600; font-weight:bold;">/</span>conf<span style="color:#006600; font-weight:bold;">/</span>nginx.<span style="color:#9900CC;">conf</span>
&nbsp;
nginx <span style="color:#006600; font-weight:bold;">-</span>v
nginx <span style="color:#006600; font-weight:bold;">-</span>V
sudo nginx <span style="color:#008000; font-style:italic;"># start server</span>
sudo nginx <span style="color:#006600; font-weight:bold;">-</span>t
&nbsp;
<span style="color:#CC0066; font-weight:bold;">open</span> http:<span style="color:#006600; font-weight:bold;">//</span>localhost:<span style="color:#006666;">80</span>
<span style="color:#CC0066; font-weight:bold;">open</span> http:<span style="color:#006600; font-weight:bold;">//</span>localhost:<span style="color:#006666;">80</span><span style="color:#006600; font-weight:bold;">/</span>50x.<span style="color:#9900CC;">html</span>
&nbsp;
sudo nano <span style="color:#006600; font-weight:bold;">/</span>usr<span style="color:#006600; font-weight:bold;">/</span>local<span style="color:#006600; font-weight:bold;">/</span>nginx<span style="color:#006600; font-weight:bold;">/</span>conf<span style="color:#006600; font-weight:bold;">/</span>nginx.<span style="color:#9900CC;">conf</span> <span style="color:#008000; font-style:italic;"># editing ... server { listen 8080; ...</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># reload configuration</span>
sudo kill <span style="color:#006600; font-weight:bold;">-</span>HUP <span style="color:#996600;">`cat /usr/local/nginx/logs/nginx.pid`</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># stop server</span>
sudo kill <span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">15</span> $<span style="color:#006600; font-weight:bold;">&#40;</span>ps <span style="color:#006600; font-weight:bold;">-</span>auxxx <span style="color:#006600; font-weight:bold;">|</span> egrep <span style="color:#996600;">&quot;[n]ginx.*master&quot;</span> <span style="color:#006600; font-weight:bold;">|</span> awk <span style="color:#996600;">'{ print $2 }'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#006600; font-weight:bold;">/</span>dev<span style="color:#006600; font-weight:bold;">/</span>null</pre></td></tr></table></div>

<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Fcompile-install-nginx-web-server%2F&amp;title=Compile%20%26%23038%3B%20install%20Nginx%20web%20server" id="wpa2a_12"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/compile-install-nginx-web-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Renaming your .rhtml to .erb on EdgeRails</title>
		<link>http://www.amityadav.name/renaming-your-rhtml-to-erb-on-edgerails/</link>
		<comments>http://www.amityadav.name/renaming-your-rhtml-to-erb-on-edgerails/#comments</comments>
		<pubDate>Mon, 16 Jun 2008 04:43:20 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/renaming-your-rhtml-to-erb-on-edgerails/</guid>
		<description><![CDATA[?View Code RUBY1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ## just slap this in your rake file or in lib/tasks &#160; namespace 'views' do desc 'Renames all your rhtml views to erb' task 'rename' do Dir.glob&#40;'app/views/**/*.rhtml'&#41;.each do &#124;file&#124; puts `svn mv [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p50code6'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p506"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code" id="p50code6"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">## just slap this in your rake file or in lib/tasks</span>
&nbsp;
namespace <span style="color:#996600;">'views'</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  desc <span style="color:#996600;">'Renames all your rhtml views to erb'</span>
  task <span style="color:#996600;">'rename'</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    <span style="color:#CC00FF; font-weight:bold;">Dir</span>.<span style="color:#9900CC;">glob</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'app/views/**/*.rhtml'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>file<span style="color:#006600; font-weight:bold;">|</span>
      <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">`svn mv #{file} #{file.gsub(/<span style="color:#000099;">\.</span>rhtml$/, '.erb')}`</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
 <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
 <span style="color:#008000; font-style:italic;">## or if you have rhtml and rxml you could probably use the following (untested)</span>
&nbsp;
 namespace <span style="color:#996600;">'views'</span> <span style="color:#9966CC; font-weight:bold;">do</span>
   desc <span style="color:#996600;">'Renames all your rhtml views to erb'</span>
   task <span style="color:#996600;">'rename'</span> <span style="color:#9966CC; font-weight:bold;">do</span>
     <span style="color:#CC00FF; font-weight:bold;">Dir</span>.<span style="color:#9900CC;">glob</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'app/views/**/*.rhtml'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>file<span style="color:#006600; font-weight:bold;">|</span>
       <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">`svn mv #{file} #{file.gsub(/<span style="color:#000099;">\.</span>(rhtml|rxml)$/, '.erb')}`</span>
     <span style="color:#9966CC; font-weight:bold;">end</span>
   <span style="color:#9966CC; font-weight:bold;">end</span>
 <span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Frenaming-your-rhtml-to-erb-on-edgerails%2F&amp;title=Renaming%20your%20.rhtml%20to%20.erb%20on%20EdgeRails" id="wpa2a_14"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/renaming-your-rhtml-to-erb-on-edgerails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Cheatsheets</title>
		<link>http://www.amityadav.name/rails-cheatsheets/</link>
		<comments>http://www.amityadav.name/rails-cheatsheets/#comments</comments>
		<pubDate>Fri, 04 Apr 2008 11:48:41 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[cheatsheet]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[rails cheatsheet]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/rails-cheatsheets/</guid>
		<description><![CDATA[Here are the rails cheatsheet&#8217;s which will help you to get a good overview of how things work in RAILS. Full Ruby on Rails cheatsheet Rails Assertions RJS Cheatsheet REST Cheatsheet Rails Refrence Rails Migration Rails File Cheatsheet Form Helpers Asserts in Rails Active Record cheatsheet rubyonrails-cheatsheet.pdf]]></description>
			<content:encoded><![CDATA[<p>Here are the rails cheatsheet&#8217;s which will help you to get a good overview of how things work in RAILS.</p>
<p><a href="http://www.amityadav.name/rails-cheatsheets/full-ruby-on-rails-cheatsheet/" rel="attachment wp-att-18" title="Full Ruby on Rails cheatsheet">Full Ruby on Rails cheatsheet</a></p>
<p><a href="http://www.amityadav.name/rails-cheatsheets/rails-assertions/" rel="attachment wp-att-17" title="Rails Assertions">Rails Assertions</a></p>
<p><a href="http://www.amityadav.name/rails-cheatsheets/rails-assertions/" rel="attachment wp-att-17" title="Rails Assertions"></a><a href="http://www.amityadav.name/rails-cheatsheets/rjs-cheatsheet/" rel="attachment wp-att-16" title="RJS Cheatsheet">RJS Cheatsheet</a></p>
<p><a href="http://www.amityadav.name/rails-cheatsheets/rest-cheatsheet/" rel="attachment wp-att-15" title="REST Cheatsheet">REST Cheatsheet</a></p>
<p><a href="http://www.amityadav.name/rails-cheatsheets/rest-cheatsheet/" rel="attachment wp-att-15" title="REST Cheatsheet"></a><a href="http://www.amityadav.name/rails-cheatsheets/rails-refrence/" rel="attachment wp-att-14" title="Rails Refrence">Rails Refrence</a></p>
<p><a href="http://www.amityadav.name/rails-cheatsheets/rails-refrence/" rel="attachment wp-att-14" title="Rails Refrence"></a><a href="http://www.amityadav.name/rails-cheatsheets/rails-migration/" rel="attachment wp-att-13" title="Rails Migration">Rails Migration</a></p>
<p><a href="http://www.amityadav.name/rails-cheatsheets/rails-migration/" rel="attachment wp-att-13" title="Rails Migration"></a><a href="http://www.amityadav.name/rails-cheatsheets/rails-file-cheatsheet/" rel="attachment wp-att-12" title="Rails File Cheatsheet">Rails File Cheatsheet</a></p>
<p><a href="http://www.amityadav.name/rails-cheatsheets/rails-file-cheatsheet/" rel="attachment wp-att-12" title="Rails File Cheatsheet"></a><a href="http://www.amityadav.name/rails-cheatsheets/form-helpers/" rel="attachment wp-att-11" title="Form Helpers">Form Helpers</a></p>
<p><a href="http://www.amityadav.name/rails-cheatsheets/asserts-in-rails/" rel="attachment wp-att-10" title="Asserts in Rails">Asserts in Rails</a></p>
<p><a href="http://www.amityadav.name/rails-cheatsheets/active-record-cheatsheet/" rel="attachment wp-att-9" title="Active Record cheatsheet">Active Record cheatsheet</a></p>
<p><a href="http://www.amityadav.name/rails-cheatsheets/8/" rel="attachment wp-att-8" title="rubyonrails-cheatsheet.pdf">rubyonrails-cheatsheet.pdf</a></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Frails-cheatsheets%2F&amp;title=Rails%20Cheatsheets" id="wpa2a_16"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/rails-cheatsheets/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>OpenID Rails Integration</title>
		<link>http://www.amityadav.name/openid-rails-integration/</link>
		<comments>http://www.amityadav.name/openid-rails-integration/#comments</comments>
		<pubDate>Fri, 21 Mar 2008 15:19:29 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Openid]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/?p=3</guid>
		<description><![CDATA[Introduction How many times have you walked away from some Internet forum because you could not remember your login ID or password, and just did not want to go through the tedium of registering again? Or gone back to re-register yourself only to forget you password the next day? Remembering all those login IDs and [...]]]></description>
			<content:encoded><![CDATA[<p align="justify"><font color="#339966"><u><strong>Introduction</strong></u></font><br />
How many times have you walked away from some Internet forum because you could not remember your login ID or password, and just did not want to go through the tedium of registering again? Or gone back to re-register yourself only to forget you password the next day? Remembering all those login IDs and passwords is indeed an onerous task and one more registration for a new site seems like one too many. We have all tried to get around these problems by jotting down passwords on pieces of paper or sticking notes to our terminal &#8211; all potentially dangerous practices that defeat the very purpose of keeping a digital identity secure.</p>
<p>If you had the choice of a single user ID and password combination &#8211; essentially a single digital identity &#8211; imagine how easy it might become to sign up or sign in to new sites.<font color="#339966"><u></u></font></p>
<p><font color="#339966"><u><strong>What is Openid?</strong></u></font><br />
OpenID is a single sign-on system, which allows internet users to log on to many different web sites using a single digital identity, eliminating the need for a different user name and password for each site. OpenID is a decentralized, free and open standard that lets users control the amount of personal information they provide.<font color="#339966"><u></u></font></p>
<p><font color="#339966"><u><strong>Overview of the authentication process</strong></u></font><br />
When consuming OpenID what you are trying to do is ask the user for their OpenID (which is a URL) then ascertain from their OpenID server that they actually own this OpenID. Once you know that they own the OpenID you can then wack it in the session (and use it as a really lightweight means of identifying users between visits) or key it in with your own application specific account data if you need more power. This article is going to take you up to and including verifying the user&#8217;s OpenID. What you do with it is left to your imagination.</p>
<p>On a more granular level the verification process breaks down into these steps:<br />
1. Get the user to give you their OpenID URL.<br />
2. &#8216;Begin&#8217; the verification process whereby your OpenID library of choice will work out the users OpenID server and, if successful, provide you with a redirect URL.<br />
3. Redirect the user to the given redirect URL. You specify a return URL within this URL.<br />
4. The user goes to their OpenID server, logs in and authorizes your site&#8217;s verification request and is then redirected back to your return URL.<br />
5. Your server &#8216;completes&#8217; the verification request and, if successful, confirms that this user owns this OpenID. The end.</p>
<p align="justify"> So that&#8217;s essentially it. Some of the details of the transactions between your server, the user&#8217;s delegates and the OpenID are pretty complex but fortunately for us there are lots of good libraries for most platforms that mean you don&#8217;t need to bugger about with the crypotography and stuff. Woo hoo. For these examples we are going to use the ruby-openid gem but you can choose your own. Also note that East Media have a OpenID Consumer plugin for Rails that wraps even more detail with some generators but it&#8217;s good to understand the concepts before you let something write your code for you.</p>
<p align="justify">&nbsp;</p>
<p align="justify"><font color="#339966"><u><strong>Get your library sorted</strong></u></font></p>
<p>That&#8217;s easy. For us Rubyists its:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p3code19'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p319"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p3code19"><pre class="ruby" style="font-family:monospace;">$ sudo gem install ruby<span style="color:#006600; font-weight:bold;">-</span>openid</pre></td></tr></table></div>

<p><font color="#339966"><u><strong>Create your OpenID consuming controller</strong></u></font></p>
<p>We are going to try to be as RESTy as possible here so we&#8217;ll create a singleton resource called openid. In routes.rb:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p3code20'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p320"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p3code20"><pre class="ruby" style="font-family:monospace;">map.<span style="color:#9900CC;">resource</span> <span style="color:#ff3333; font-weight:bold;">:openid</span>, <span style="color:#ff3333; font-weight:bold;">:member</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:complete</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; get <span style="color:#006600; font-weight:bold;">&#125;</span></pre></td></tr></table></div>

<p>Then we&#8217;ll set up a simple controller. Firstly, we&#8217;ll need to require the ruby-openid gem here. We are also going to need a method that gives us an OpenID consumer object which is the single most complex part of this whole thing (and it isn&#8217;t complex). First, here&#8217;s the skeleton:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://www.amityadav.name/wp-content/plugins/wp-codebox/wp-codebox.php?p=3&amp;download=openid.txt">openid.txt</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p321"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code" id="p3code21"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">&quot;openid&quot;</span><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'uri'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'openid/extensions/sreg'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'openid/store/filesystem'</span>
<span style="color:#9966CC; font-weight:bold;">class</span> OpenidController <span style="color:#006600; font-weight:bold;">&amp;</span>lt; ApplicationControlle
    <span style="color:#9966CC; font-weight:bold;">def</span> index
        <span style="color:#0066ff; font-weight:bold;">@title</span> = <span style="color:#996600;">'Welcome'</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> new
        <span style="color:#008000; font-style:italic;"># TODO: show a form requesting the user's OpenID</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#9966CC; font-weight:bold;">begin</span>
        <span style="color:#008000; font-style:italic;"># TODO: begin the OpenID verification process</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> complete
        <span style="color:#008000; font-style:italic;"># TODO: omplete the OpenID verification process</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> requested_url
        <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#996600;">&quot;#{request.protocol + request.host_with_port + request.relative_url_root + request.path}&quot;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
protected
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> openid_consumer
        <span style="color:#0066ff; font-weight:bold;">@openid_consumer</span> <span style="color:#006600; font-weight:bold;">||</span>= <span style="color:#6666ff; font-weight:bold;">OpenID::Consumer</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>session, <span style="color:#6666ff; font-weight:bold;">OpenID::Store::Filesystem</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;#{RAILS_ROOT}/tmp/openid&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>The OpenID::Consumer constructor takes two arguments, the first one should be a hash like object that holds session data. That&#8217;s always going to be session for Rails. The second one takes a file store object which is used to store state information for the verification process. There&#8217;s lots (including an ActiveRecord store) but for many apps the filesystem store is fine.<br />
<font color="#339966"><u></u></font></p>
<p><font color="#339966"><u><strong> Getting the user&#8217;s OpenID</strong></u></font><br />
The new action just needs to show a simple form posting the OpenID to the create action:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p3code22'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p322"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p3code22"><pre class="ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&lt;</span>h1<span style="color:#006600; font-weight:bold;">&gt;&lt;%</span>= <span style="color:#0066ff; font-weight:bold;">@title</span> <span style="color:#006600; font-weight:bold;">%&gt;&lt;/</span>h1<span style="color:#006600; font-weight:bold;">&gt;</span>
<span style="color:#006600; font-weight:bold;">&lt;</span>div<span style="color:#006600; font-weight:bold;">&gt;&lt;</span>strong<span style="color:#006600; font-weight:bold;">&gt;&lt;%</span>= flash<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:message</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">%&gt;&lt;/</span>strong<span style="color:#006600; font-weight:bold;">&gt;&lt;/</span>div<span style="color:#006600; font-weight:bold;">&gt;</span>
<span style="color:#006600; font-weight:bold;">&lt;</span>div<span style="color:#006600; font-weight:bold;">&gt;&lt;</span>strong<span style="color:#006600; font-weight:bold;">&gt;&lt;%</span>= flash<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:error</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">%&gt;&lt;/</span>strong<span style="color:#006600; font-weight:bold;">&gt;&lt;/</span>div<span style="color:#006600; font-weight:bold;">&gt;</span>
Please login with your OpenID Identity URL
<span style="color:#006600; font-weight:bold;">&lt;</span>div id=<span style="color:#996600;">&quot;verify-form&quot;</span><span style="color:#006600; font-weight:bold;">&gt;</span>
  <span style="color:#006600; font-weight:bold;">&lt;%</span>= start_form_tag <span style="color:#ff3333; font-weight:bold;">:action</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'begin'</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>    Identity URL:
<span style="color:#006600; font-weight:bold;">&lt;</span>input name=<span style="color:#996600;">&quot;openid_url&quot;</span> style=<span style="color:#996600;">&quot;width: 200px&quot;</span> type=<span style="color:#996600;">&quot;text&quot;</span> <span style="color:#006600; font-weight:bold;">/&gt;</span>
<span style="color:#006600; font-weight:bold;">&lt;</span>input value=<span style="color:#996600;">&quot;Verify&quot;</span> type=<span style="color:#996600;">&quot;submit&quot;</span> <span style="color:#006600; font-weight:bold;">/&gt;&lt;/</span>div<span style="color:#006600; font-weight:bold;">&gt;</span></pre></td></tr></table></div>

<p>Note that it&#8217;s convention to call the field openid_url so browsers will autocomplete nicely. They also recommend that you embed the OpenID logo in the form field. Get the logo then try some CSS like this:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p3code23'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p323"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p3code23"><pre class="ruby" style="font-family:monospace;">    <span style="color:#008000; font-style:italic;">#openid_url {background: url(/images/login-bg.gif) no-repeat #FFF 5px;padding-left: 25px;}</span></pre></td></tr></table></div>

<p><font color="#339966"><u><strong>Beginning the verification</strong></u></font></p>
<p>The create action is going to be responsible for kicking off the process:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p3code24'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p324"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p3code24"><pre class="ruby" style="font-family:monospace;">    <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#9966CC; font-weight:bold;">begin</span>  
        openid_url = params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:openid_url</span><span style="color:#006600; font-weight:bold;">&#93;</span>open_id_response = openid_consumer.<span style="color:#9966CC; font-weight:bold;">begin</span><span style="color:#006600; font-weight:bold;">&#40;</span>openid_url<span style="color:#006600; font-weight:bold;">&#41;</span>
        redirect_to  open_id_response.<span style="color:#9900CC;">redirect_url</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span>request.<span style="color:#9900CC;">protocol</span> <span style="color:#006600; font-weight:bold;">+</span> request.<span style="color:#9900CC;">host_with_port</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">'/'</span><span style="color:#006600; font-weight:bold;">&#41;</span>, url_for<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:action</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#996600;">'complete'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>We simply get the OpenID and pass it to the begin method of our consumer object to get a response. We then handle the status of the response which can have a number of states. For this super simple example we are just going to look for success but in a production app you&#8217;ll need to handle error states more usefully.</p>
<p>If the response was successful we call redirect_url passing the trust root and the return URL. The return URL is simply our complete action. The trust root is normally the homepage URL of your site. We then redirect the user to the resulting URL where the user logs in to their OpenID server, authorises your verification request and is (normally) redirected to return URL you provided.</p>
<p><strong><u><font color="#339966"> Completing the verification</font></u></strong></p>
<p>When the user is redirected back to your application the server will append information about the response in the query string which the OpenID library will unpack:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p3code25'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p325"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code" id="p3code25"><pre class="ruby" style="font-family:monospace;">    <span style="color:#9966CC; font-weight:bold;">def</span> complete  
        params_with_path = params.<span style="color:#9900CC;">reject</span><span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>key, value<span style="color:#006600; font-weight:bold;">|</span> request.<span style="color:#9900CC;">path_parameters</span><span style="color:#006600; font-weight:bold;">&#91;</span>key<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
        open_id_response =     openid_consumer.<span style="color:#9900CC;">complete</span><span style="color:#006600; font-weight:bold;">&#40;</span>params_with_path, requested_url<span style="color:#006600; font-weight:bold;">&#41;</span>  <span style="color:#9966CC; font-weight:bold;">case</span> open_id_response.<span style="color:#9900CC;">statuswhen</span> 
&nbsp;
        <span style="color:#6666ff; font-weight:bold;">OpenID::Consumer::FAILURE</span>
                <span style="color:#9966CC; font-weight:bold;">if</span> open_id_esponse.<span style="color:#9900CC;">identity_url</span>
                    flash<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:message</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot;Verification of #{open_id_response.identity_url} failed. &quot;</span>
                <span style="color:#9966CC; font-weight:bold;">else</span>
                    flash<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:message</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot;Verification failed. &quot;</span>
                <span style="color:#9966CC; font-weight:bold;">end</span>
                flash<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:message</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">+</span>= open_id_response.<span style="color:#9900CC;">message</span>.<span style="color:#9900CC;">to_s</span>
        <span style="color:#9966CC; font-weight:bold;">when</span> <span style="color:#6666ff; font-weight:bold;">OpenID::Consumer::SUCCESS</span>
                flash<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:message</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot;You have successfully verified #{open_id_response.identity_url} as your identity.&quot;</span>
                <span style="color:#9966CC; font-weight:bold;">if</span> !params.<span style="color:#9900CC;">blank</span>?
                    flash<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:message</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;&lt;hr /&gt; With simple registration fields:&quot;</span>
                    params.<span style="color:#9900CC;">each</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>k,v<span style="color:#006600; font-weight:bold;">|</span> flash<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:message</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;&lt;strong&gt;#{k}&lt;/strong&gt;: #{v}&quot;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
                <span style="color:#9966CC; font-weight:bold;">end</span>   
         <span style="color:#9966CC; font-weight:bold;">when</span> <span style="color:#6666ff; font-weight:bold;">OpenID::Consumer::CANCEL</span>
                    flash<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:message</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot;Verification cancelled.&quot;</span>
         <span style="color:#9966CC; font-weight:bold;">else</span>
                    flash<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:message</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot;Unknown response status: #{open_id_response.status}&quot;</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
        redirect_to <span style="color:#ff3333; font-weight:bold;">:action</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#996600;">'index'</span>
    <span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>After passing the params hash containing all the info that the OpenID server sent us to the complete method we are given a response status to handle. Again for production apps more states should be handled but here, if the complete was successful we have completed the process. Here we just store the identity_url given in the session but at this point we could also do something like:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p3code26'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p326"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p3code26"><pre class="ruby" style="font-family:monospace;">session<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:user</span><span style="color:#006600; font-weight:bold;">&#93;</span> = User.<span style="color:#9900CC;">find_by_openid_url</span><span style="color:#006600; font-weight:bold;">&#40;</span>response.<span style="color:#9900CC;">identity_url</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p>Which would grab the users local account data based on the OpenID. Easy as pasty. However, there&#8217;s a few more bits and bobs you might want to know about.</p>
<p><font color="#339966"><u><strong> Simple Registration Extension (SReg)</strong></u></font></p>
<p>SReg is a basic means by which you can request additional information about the user from their OpenID server which you might normally use to prefill account details or other form fields. The information you can request access to is in the spec but there&#8217;s not much there at the moment. It&#8217;s still kind of useful. To request this information you need to add parameters to the redirect URL which is of course handled for you by your library. Revisiting the create action, we just add a call to add_extension_arg:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p3code27'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p327"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code" id="p3code27"><pre class="ruby" style="font-family:monospace;">    <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#9966CC; font-weight:bold;">begin</span>  
        openid_url = params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:openid_url</span><span style="color:#006600; font-weight:bold;">&#93;</span>
        response = openid_consumer.<span style="color:#9966CC; font-weight:bold;">begin</span> openid_url  
        <span style="color:#9966CC; font-weight:bold;">if</span> response.<span style="color:#9900CC;">status</span> == <span style="color:#6666ff; font-weight:bold;">OpenID::SUCCESS</span>
            response.<span style="color:#9900CC;">add_extension_arg</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'sreg'</span>,<span style="color:#996600;">'required'</span>,<span style="color:#996600;">'email'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#008000; font-style:italic;"># &lt;== here...</span>
            response.<span style="color:#9900CC;">add_extension_arg</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'sreg'</span>,<span style="color:#996600;">'optional'</span>,<span style="color:#996600;">'nickname,gender'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#008000; font-style:italic;"># &lt;== ...and here</span>
            redirect_url = response.<span style="color:#9900CC;">redirect_url</span><span style="color:#006600; font-weight:bold;">&#40;</span>home_url, complete_openid_url<span style="color:#006600; font-weight:bold;">&#41;</span>
            redirect_to redirect_url
            <span style="color:#0000FF; font-weight:bold;">return</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
        flash<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:error</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot;Couldn't find an OpenID for that URL&quot;</span>
        render <span style="color:#ff3333; font-weight:bold;">:action</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#ff3333; font-weight:bold;">:new</span>
    <span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>Then in the complete action, extract the returned information:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p3code28'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p328"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code" id="p3code28"><pre class="ruby" style="font-family:monospace;">    <span style="color:#9966CC; font-weight:bold;">def</span> complete  
        response = openid_consumer.<span style="color:#9900CC;">complete</span> params  
        <span style="color:#9966CC; font-weight:bold;">if</span> response.<span style="color:#9900CC;">status</span> == <span style="color:#6666ff; font-weight:bold;">OpenID::SUCCES</span>
            Ssession<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:openid</span><span style="color:#006600; font-weight:bold;">&#93;</span> = response.<span style="color:#9900CC;">identity_url</span>   <span style="color:#008000; font-style:italic;"># the user is now logged in with OpenID!</span>
            <span style="color:#0066ff; font-weight:bold;">@registration_info</span> = response.<span style="color:#9900CC;">extension_response</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'sreg'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#008000; font-style:italic;"># &amp;lt;= { 'name' =&amp;gt; 'Dan Webb', etc... }</span>
            redirect_to home_url
            <span style="color:#0000FF; font-weight:bold;">return</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
        flash<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:error</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">'Could not log on with your OpenID'</span>
        redirect_to new_openid_url
    <span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p><font color="#339966"><u><strong>Immediate mode</strong></u></font></p>
<p>Immediate mode allows you to attempt to verify the user without them leaving your site at all. This is normally possible if, during the first time you attempt to verify a user, they choose to always allow you to verify them and offers a slightly more streamlined login experience.</p>
<p>To implement this we first pass an extra argument to redirect_url:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p3code29'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p329"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code" id="p3code29"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#9966CC; font-weight:bold;">begin</span>  
  openid_url = params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:openid_url</span><span style="color:#006600; font-weight:bold;">&#93;</span>
  response = openid_consumer.<span style="color:#9966CC; font-weight:bold;">begin</span> openid_url
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">if</span> response.<span style="color:#9900CC;">status</span> == <span style="color:#6666ff; font-weight:bold;">OpenID::SUCCESS</span>
   redirect_url = response.<span style="color:#9900CC;">redirect_url</span><span style="color:#006600; font-weight:bold;">&#40;</span>home_url, complete_openid_url, <span style="color:#0000FF; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#008000; font-style:italic;"># &lt;== here</span>
   redirect_to redirect_url
   <span style="color:#0000FF; font-weight:bold;">return</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  flash<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:error</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot;Couldn't find an OpenID for that URL&quot;</span>
  render <span style="color:#ff3333; font-weight:bold;">:action</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:new</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>Then ensure that our complete action handles the OpenID::SETUP_NEEDED status by redirecting them to the OpenID server&#8217;s setup page:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p3code30'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p330"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code" id="p3code30"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> complete
  response = openid_consumer.<span style="color:#9900CC;">complete</span> params
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">case</span> response.<span style="color:#9900CC;">status</span>
  <span style="color:#9966CC; font-weight:bold;">when</span> <span style="color:#6666ff; font-weight:bold;">OpenID::SUCCESS</span>
    session<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:openid</span><span style="color:#006600; font-weight:bold;">&#93;</span> = response.<span style="color:#9900CC;">identity_url</span>
    redirect_to home_url
    <span style="color:#0000FF; font-weight:bold;">return</span>
  <span style="color:#9966CC; font-weight:bold;">when</span> <span style="color:#6666ff; font-weight:bold;">OpenID::SETUP_NEEDED</span>
    redirect_to response.<span style="color:#9900CC;">setup_url</span> <span style="color:#008000; font-style:italic;"># &lt;== here!</span>
    <span style="color:#0000FF; font-weight:bold;">return</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  flash<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:error</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">'Could not log on with your OpenID'</span>
  redirect_to new_openid_url
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p><strong>Fin</strong></p>
<p>So that&#8217;s it.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Fopenid-rails-integration%2F&amp;title=OpenID%20Rails%20Integration" id="wpa2a_18"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/openid-rails-integration/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

