<?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>BenCurtis.com</title>
	<atom:link href="http://www.bencurtis.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bencurtis.com</link>
	<description>Speculations on Web Development by Benjamin Curtis</description>
	<lastBuildDate>Thu, 29 Jul 2010 21:48:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Interesting breakage in Rails 3 RC</title>
		<link>http://www.bencurtis.com/2010/07/interesting-breakage-in-rails-3-rc/</link>
		<comments>http://www.bencurtis.com/2010/07/interesting-breakage-in-rails-3-rc/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 21:48:49 +0000</pubDate>
		<dc:creator>ben</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.bencurtis.com/?p=283</guid>
		<description><![CDATA[My latest project, UploadJuicer is running on Rails 3, and I&#8217;m loving it.  Back in the Rails 3 beta 1 days, there were still a lot of rough edges, but beta 4 has been great so far.  Until I wanted to upgrade UploadJuicer to Rails 3 RC (1).  After the upgrade, I [...]]]></description>
			<content:encoded><![CDATA[<p>My latest project, <a href="http://www.uploadjuicer.com/">UploadJuicer</a> is running on Rails 3, and I&#8217;m loving it.  Back in the Rails 3 beta 1 days, there were still a lot of rough edges, but beta 4 has been great so far.  Until I wanted to upgrade UploadJuicer to Rails 3 RC (1).  After the upgrade, I got this:</p>
<p>ActionController::RoutingError (uninitialized constant ApplicationController::AuthenticationHelpers)</p>
<p>AuthenticationHelpers happens to be the first module I include from ApplicationController, and it lives in lib/authentication_helpers.rb.  After a bid of head-scratching as to why something that has worked for ages and ages in Rails suddenly stopped working (and in between a beta and an RC release, to boot!), I remembered this change in config/application.rb from running rake rails:update:</p>
<p><code lang="ruby"><br />
# Custom directories with classes and modules you want to be autoloadable.<br />
# config.autoload_paths += %W(#{config.root}/extras)<br />
</code></p>
<p>That looked promising, so I uncommented it, changed extras to lib, and bam, problem solved.  Life on the edge is an adventure. :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bencurtis.com/2010/07/interesting-breakage-in-rails-3-rc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unwrapping UploadJuicer</title>
		<link>http://www.bencurtis.com/2010/07/unwrapping-uploadjuicer/</link>
		<comments>http://www.bencurtis.com/2010/07/unwrapping-uploadjuicer/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 14:33:53 +0000</pubDate>
		<dc:creator>ben</dc:creator>
				<category><![CDATA[AWS]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.bencurtis.com/?p=279</guid>
		<description><![CDATA[It says something about the sorry state of my blogging lately that my blog is the last place I&#8217;m announcing my latest project, Juicer. :)  It&#8217;s a handy service for offloading image uploading and resizing from your web app.  Now you don&#8217;t have to tie up your server to handle long uploads or [...]]]></description>
			<content:encoded><![CDATA[<p>It says something about the sorry state of my blogging lately that my blog is the last place I&#8217;m announcing my latest project, <a href="http://www.uploadjuicer.com/">Juicer</a>. :)  It&#8217;s a handy service for offloading image uploading and resizing from your web app.  Now you don&#8217;t have to tie up your server to handle long uploads or to do a bunch of thumbnails.  You can keep your app super-responsive for the core of what it does, and leave the uploads and resizes to us.</p>
<p>Though my blog is the last place I announced the project, it&#8217;ll be the first place I announce the Ruby gem that goes along with it. :)  I just published a gem that uses the Juicer API (via RestClient) and makes it pretty easy to integrate Juicer with a Rails 3 app.  I&#8217;ve done the hard work of getting the direct-to-s3 upload with swfupload working for you, so all you have to do is make a few tweaks to your model and you have uploads and thumbnails done for you.  You can get at the gem (and a sample Rails 3 app) <a href="http://github.com/uploadjuicer/">at Github</a>.</p>
<p>We&#8217;ll be posting more about <a href="http://www.uploadjuicer.com/">Juicer</a> at the <a href="http://blog.uploadjuicer.com/">Juicer blog</a>, but I imagine I&#8217;ll mention things about it here from time to time. :)  And hopefully I&#8217;ll get around to posting some of the fun code-related things that make up the service.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bencurtis.com/2010/07/unwrapping-uploadjuicer/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Facebook Rails Integration with OAuth2</title>
		<link>http://www.bencurtis.com/2010/04/facebook-rails-integration-with-oauth2/</link>
		<comments>http://www.bencurtis.com/2010/04/facebook-rails-integration-with-oauth2/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 18:04:54 +0000</pubDate>
		<dc:creator>ben</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.bencurtis.com/?p=276</guid>
		<description><![CDATA[This is simply awesome.  Facebook launches a new API using OAuth2, making it much easier to integrate with Facebook from your Rails app, and Michael Bleigh quickly churns out a new oauth2 gem.
Having dealt with the pain of Facebook integrations recently, and having really enjoyed using OAuth, I had to dive in.  The result [...]]]></description>
			<content:encoded><![CDATA[<p>This is simply awesome.  Facebook launches a new API using OAuth2, making it much easier to integrate with Facebook from your Rails app, and Michael Bleigh quickly churns out a new <a href="http://intridea.com/2010/4/22/oauth2-gem-just-in-time-for-facebook-graph">oauth2 gem</a>.</p>
<p>Having dealt with the pain of Facebook integrations recently, and having really enjoyed using OAuth, I had to dive in.  The result is a new Rails Kit! :)  The <a href="http://railskits.com/facebook">Facebook API Rails Kit</a> gives you a sample Rails app that integrates with Facebook and shows you how to post to a Facebook user&#8217;s stream.  Check it out &#8212; I think you&#8217;ll like it.  I would have <strong>loved</strong> to have had this a few months ago. :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bencurtis.com/2010/04/facebook-rails-integration-with-oauth2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Testing an OAuth Provider in your Rails App</title>
		<link>http://www.bencurtis.com/2010/03/testing-an-oauth-provider-in-your-rails-app/</link>
		<comments>http://www.bencurtis.com/2010/03/testing-an-oauth-provider-in-your-rails-app/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 19:20:21 +0000</pubDate>
		<dc:creator>ben</dc:creator>
				<category><![CDATA[OAuth]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.bencurtis.com/?p=268</guid>
		<description><![CDATA[Recently I received a request from another B2B SaaS vendor to integrate with Catch the Best, so their users could pull their data from Catch the Best into this app.  This is a classic use-case for OAuth, so I dove in to learning how to make my Rails app an OAuth provider.  Well, [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I received a request from another B2B SaaS vendor to integrate with <a href="http://catchthebest.com">Catch the Best</a>, so their users could pull their data from Catch the Best into this app.  This is a classic use-case for <a href="http://oauth.net/">OAuth</a>, so I dove in to learning how to make my Rails app an OAuth provider.  Well, thanks to the <a href="http://oauth.rubyforge.org/">OAuth gem</a> and the <a href="http://agilewebdevelopment.com/plugins/oauth_plugin">OAuth Rails plugin</a>, it only took an hour or two to do.</p>
<p>However, since it took a little longer than it should have to do some testing of the app from the console, I thought I&#8217;d post this code in case it proves helpful to someone else working on this.  My goal was to manually verify that the access control (the before filter) was working properly, so I could email the details on the OAuth endpoint to this other vendor and be reasonably sure it would work well for them.  Here&#8217;s the code:<br />
<span id="more-268"></span><br />
<script src="http://gist.github.com/330890.js?file=oauth_provider_console.rb"></script></p>
<p><noscript><br />
<code lang="ruby"><br />
ca = ClientApplication.create(:name =&gt; 'Test Consumer App', :url =&gt; 'http://consumerapp.local')</p>
<p>consumer = OAuth::Consumer.new(ca.key, ca.secret, :site =&gt; 'http://localhost:3000')<br />
request_token = consumer.get_request_token</p>
<p>`open #{request_token.authorize_url}`</p>
<p># after POSTing that form...</p>
<p>db_request_token = RequestToken.last</p>
<p># the POST would redirect to #{ca.callback_url}?oauth_token=#{db_request_token.token}&amp;oauth_verifier=#{db_request_token.verifier} if ca.callback_url is not nil</p>
<p></code><code lang="ruby">access_token = OAuth::RequestToken.new(consumer, request_token.token, db_request_token.token).get_access_token(:oauth_verifier =&gt; db_request_token.verifier)<br />
access_token.get('/some/protected/action')<br />
</code></p>
<p></noscript></p>
<p>On line 1 I create a new ClientAppliction in my app.  This is basically &#8220;registering&#8221; the other vendor&#8217;s app as a application that my users choose to receive access to their data.  In other words, this is the same thing that developers do when they register a new application with Twitter when they want to get access to a Twitter user&#8217;s account via OAuth, and then the Twitter user can grant access to that registered application.  This is the only line in the code that is related to the provider.</p>
<p>Line 3 creates a new consumer, using the key and secret generated by the provider, and line 4 creates a request token that the other vendor (the consumer app) would use to send their user to my site to request permission (line 6).  After the user clicks the &#8220;grant access&#8221; checkbox and submits the form, a new RequestToken is created for the consumer (used in line 10) and optionally redirects back to the consumer app.</p>
<p>On line 14 I get an access token based on the information received from the ResponseToken (or from the redirect, in the real world), which allows the consumer to act in the place of the user, as if the consumer app were logged in as the user.  Finally, line 15 loads a protected action from the app that blocks access with either the oauth_required or the login_or_oauth_required before filter.</p>
<p>Of course you&#8217;d want to put something like this into a functional test, but it&#8217;s nice to be able to see things work in the console, too.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bencurtis.com/2010/03/testing-an-oauth-provider-in-your-rails-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why Won&#8217;t FB.Connect.logoutAndRedirect work?</title>
		<link>http://www.bencurtis.com/2010/03/why-wont-fb-connect-logoutandredirect-work/</link>
		<comments>http://www.bencurtis.com/2010/03/why-wont-fb-connect-logoutandredirect-work/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 14:43:24 +0000</pubDate>
		<dc:creator>ben</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.bencurtis.com/?p=262</guid>
		<description><![CDATA[I was banging my head against a Facebook Connect problem with one of my clients&#8217; Rails apps recently, and I thought I&#8217;d share a useful tidbit I gleaned from the experience, in case it can spare someone else the headache I had.
This app originally supported just plain-old users who created an account at the site [...]]]></description>
			<content:encoded><![CDATA[<p>I was banging my head against a Facebook Connect problem with one of my clients&#8217; Rails apps recently, and I thought I&#8217;d share a useful tidbit I gleaned from the experience, in case it can spare someone else the headache I had.</p>
<p>This app originally supported just plain-old users who created an account at the site with a username and password.  Then the client requested that I add Facebook Connect as an authentication option.  Using the <a href="http://facebooker.rubyforge.org/">facebooker gem</a>, most of the work was straightforward.  If a user chooses the Facebook Connect option when signing up or logging in, a User record is created and a FacebookUser record is associated with that User.  The real problem came with trying to log out a Facebook Connect user.<br />
<span id="more-262"></span><br />
As far as I can tell from the Facebook documentation, if you provide a logout at your site, and someone is logged in via Facebook Connect, you <a href="http://wiki.developers.facebook.com/index.php/Connect/Authorization_Websites#Logging_Out_Users">should call the Facebook API</a> to log that user out of Facebook, too.  This is done by using either the FB.Connect.logoutAndRedirect or the FB.Connect.logout function in the javascript API.  I wanted to send my users to the /logout URL in the application to do some additional cleanup of the User record, and to use facebooker to clear out the Facebook cookies, so the logoutAndRedirect method seemed to be the way to go.  Unfortunately, for reasons that I couldn&#8217;t immediately figure out, it would work in Safari or Chrome, but not in Firefox.</p>
<p>So, I tried using the logout javascript method as an alternative.  It accepts a callback function as an argument (and here&#8217;s the key) that gets executed immediately if the Facebook user has no current Facebook session.  Even though the logoutAndRedirect method did absolutely nothing (and returned no error) in Firefox, the logout method would call that callback (even though it didn&#8217;t log me out of Facebook).  This was progress &#8212; though I couldn&#8217;t log out of Facebook in Firefox with this function, at least I could log out of my app by redirecting to /logout in the callback, and I wouldn&#8217;t be immediately logged back in after a page load or two in Safari (which was the problem I was experiencing with just depending on the facebooker methods rather than using the javascript).</p>
<p>The trick that finally sealed the deal and got all browsers working similarly had nothing to do with the app, though&#8230; it was a browser setting.  Safari had 3rd-party cookies enabled, and Firefox didn&#8217;t.  Having that setting turned off prevented the logoutAndRedirect method from working as it should, thus preventing the redirect to the /logout URL.  Having that setting turned on caused the Facebook cookies to almost immediately come back, when using just the server-side code to do the logout.</p>
<p>To get everybody logged out, then, regardless of cookie settings, the way to do it is to the use FB.connect.logout with a callback function that redirects to /logout.  This successfully logs the user out of Facebook if he has third-party cookies enabled, and logs the user out of your app by destroying the current session even if he doesn&#8217;t.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bencurtis.com/2010/03/why-wont-fb-connect-logoutandredirect-work/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
