<?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>Code Iteratively &#187; software</title>
	<atom:link href="http://iterat.ive.ly/index.php/tag/software/feed/" rel="self" type="application/rss+xml" />
	<link>http://iterat.ive.ly</link>
	<description>code. cycling. music.</description>
	<lastBuildDate>Sat, 04 Sep 2010 09:31:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Upgrading your Authlogic Gem for&#160;Rails3</title>
		<link>http://iterat.ive.ly/index.php/2010/09/03/upgrading-your-authlogic-gem-for-rails3/</link>
		<comments>http://iterat.ive.ly/index.php/2010/09/03/upgrading-your-authlogic-gem-for-rails3/#comments</comments>
		<pubDate>Fri, 03 Sep 2010 08:45:17 +0000</pubDate>
		<dc:creator>Christopher Gooley</dc:creator>
				<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[rails3]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://iterat.ive.ly/?p=431</guid>
		<description><![CDATA[If you&#8217;re using Authlogic in Rails3 (or if you&#8217;re upgrading your existing app from 2.3.8 to Rails3) you really need to be using the rails3 branch of the Authlogic gem. If you&#8217;re using Bundler, this is super-easy because you just need to update your Gemfile. In your Gemfile, update the authlogic line to be: gem [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re using Authlogic in Rails3 (or if you&#8217;re upgrading your existing app from 2.3.8 to Rails3) you really need to be using the <a href="http://github.com/odorcicd/authlogic/tree/rails3">rails3 branch</a> of the Authlogic gem.  If you&#8217;re using <a href="http://gembundler.com/">Bundler</a>, this is super-easy because you just need to update your Gemfile.</p>
<p>In your Gemfile, update the authlogic line to be:</p>
<pre class="brush:ruby;gutter:false">
gem 'authlogic', :git => 'git://github.com/odorcicd/authlogic.git', :branch => 'rails3'
</pre>
<p>Now you should run <code>$ bundle install</code> to grab the new gem. Then, there are just a few more deprecated things in Rails3 that you&#8217;ll need to change in your upgraded app. I&#8217;ll try to enumerate here from memory, so please forgive me if I forget something.</p>
<p><span id="more-431"></span>First, you need to update your ApplicationController because #requesturi is outdated.  Replace it with #fullpath:</p>
<pre class="brush:ruby;gutter:false;">
def store_location
  session[:return_to] = request.fullpath
end
</pre>
<p>Second, you need to drop the filter_parameter_logging setting from your ApplicationController because it&#8217;s now handled in the new application.rb file.  Just remember to add the :password_confirmation field to the default array like so:</p>
<pre class="brush:ruby;gutter:false;">
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password, :password_confirmation]
</pre>
<p>Third, if your migration script (or the steps you followed manually) didn&#8217;t get rid of the /config/initializers/cookie_verification_secret.rb file, delete it now.  Cookie secrets are now handled in the /config/initializers/secret_token.rb file.</p>
<p>Fourth, the f.error_message construct isn&#8217;t available anymore in core rails, so you should take this opportunity to create your own better more customizable error messages.  If you really really want to keep using f.error_message you can install the dynamic_form plugin, but don&#8217;t do that.  Railscast.com did a very nice explanation of <a href="http://asciicasts.com/episodes/211-validations-in-rails-3">how to create your own shared _error_messages.html.erb view</a> (along with some other validation-related stuff.)</p>
<p>Finally, you need to make sure your generated pages include the csrf_meta_tag. <a href="http://iterat.ive.ly/index.php/2010/09/03/invalidauthenticitytoken-on-logout-attempt-using-authlogic/">Check out my previous post</a> if you&#8217;re getting an InvalidAuthenticityToken error when you hit the Logout link.</p>
<p>That should be all you need to do to have Authlogic working in Rails3 without deprecated warnings.</p>
]]></content:encoded>
			<wfw:commentRss>http://iterat.ive.ly/index.php/2010/09/03/upgrading-your-authlogic-gem-for-rails3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>InvalidAuthenticityToken on Logout when using&#160;Authlogic</title>
		<link>http://iterat.ive.ly/index.php/2010/09/03/invalidauthenticitytoken-on-logout-attempt-using-authlogic/</link>
		<comments>http://iterat.ive.ly/index.php/2010/09/03/invalidauthenticitytoken-on-logout-attempt-using-authlogic/#comments</comments>
		<pubDate>Fri, 03 Sep 2010 08:07:46 +0000</pubDate>
		<dc:creator>Christopher Gooley</dc:creator>
				<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[rails3]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://iterat.ive.ly/?p=416</guid>
		<description><![CDATA[This one took me a while to debug. When upgrading my existing application to Rails 3 almost everything was working fine except whenever I would click the Logout link I would get an error because Rails couldn&#8217;t verify that the UserSessionsController#destroy request was valid from my app. This is the error message shown: ActionController::InvalidAuthenticityToken in [...]]]></description>
			<content:encoded><![CDATA[<p>This one took me a while to debug. When upgrading my existing application to Rails 3 almost everything was working fine except whenever I would click the Logout link I would get an error because Rails couldn&#8217;t verify that the UserSessionsController#destroy request was valid from my app.</p>
<p>This is the error message shown:<br />
<code>ActionController::InvalidAuthenticityToken in User sessionsController#destroy</code></p>
<p><code>actionpack (3.0.0) lib/action_controller/metal/ request_forgery_protection.rb:96:in `verify_authenticity_token'</code></p>
<p>And the solution is simple, you just need to add the new csrf_meta_tag helper to your generated page (probably in the /views/layouts/application.html.erb file).</p>
<p><span id="more-416"></span></p>
<pre class="brush:html;highlight:7">
...
&lt;head&gt;
  &lt;meta http-equiv="content-type" content="text/html;charset=UTF-8" /&gt;
  &lt;title&gt;Some Title&lt;/title&gt;
  &lt;%= stylesheet_link_tag :all %&gt;
  &lt;%= javascript_include_tag :defaults %&gt;
  &lt;%= csrf_meta_tag %&gt;
&lt;/head&gt;
...
</pre>
<p>Line 7 is the one you care about and need to have in your html.erb file.</p>
<p>This helper includes the appropriate meta tags which make the authenticity_token available to the handleMethod javascript function.  In Rails3, links generated with the link_to helper which use a :method other than GET get passed through that handleMethod function in rails.js.  That function creates a temporary form, sets some parameters and submits it.  And if you&#8217;re using protect_from_forgery (you should be) all non-GET requests are checked to prevent Cross Site Request Forgery (CSRF).  So, if those meta tags don&#8217;t exist on your page, the handleMethod function doesn&#8217;t know what your authenticity_token is, and the request will be rejected with the error above.</p>
<p>Line 5 below is an example of my main nav logout link that was causing the problem when clicked.  No change was required to this code after doing the above fix.</p>
<pre class="brush:ruby;highlight:5">
&lt;% if !current_user %&gt;
  &lt;%= link_to "Log In", new_user_session_path %&gt; |
  &lt;%= link_to "Register", new_account_path %&gt; |
&lt;% else %&gt;
  &lt;%= link_to "Logout", user_session_path, :method =&gt; :delete %&gt; |
&lt;% end %&gt;
</pre>
<p>This isn&#8217;t specific to Authlogic&#8217;s logout click &#8211; any time you are using link_to now in Rails3 with non-GET methods, it uses unobtrusive javascript. And if you&#8217;re missing the csrf_meta_tag helper, any unobtrusive javascript posts will fail to validate. </p>
]]></content:encoded>
			<wfw:commentRss>http://iterat.ive.ly/index.php/2010/09/03/invalidauthenticitytoken-on-logout-attempt-using-authlogic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Coming Soon: Earbits Radio iPhone&#160;App</title>
		<link>http://iterat.ive.ly/index.php/2010/09/01/coming-soon-earbits-radio-iphone-app/</link>
		<comments>http://iterat.ive.ly/index.php/2010/09/01/coming-soon-earbits-radio-iphone-app/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 03:12:45 +0000</pubDate>
		<dc:creator>Christopher Gooley</dc:creator>
				<category><![CDATA[asides]]></category>
		<category><![CDATA[cool stuff]]></category>
		<category><![CDATA[earbits]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://iterat.ive.ly/?p=390</guid>
		<description><![CDATA[Earbits is a new 24&#215;7 commercial-free, subscription-free free internet radio service that just launched last Friday. Once it&#8217;s fully baked, it&#8217;s going to have some really cool artist discovery tools and great utilities for bands who want to get their music heard. I&#8217;ve been involved in the minor capacity of building the actual player used [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://earbits.com">Earbits</a> is a new 24&#215;7 commercial-free, subscription-free free internet radio service that just launched last Friday. Once it&#8217;s fully baked, it&#8217;s going to have some really cool artist discovery tools and great utilities for bands who want to get their music heard.</p>
<p>I&#8217;ve been involved in the minor capacity of building the actual player used on the website and for embedded players on partner websites. It&#8217;s been a nice refresher of using my javascript skills. And now, I&#8217;m expanding my role into building the first mobile Earbits app for the iPhone. Since I&#8217;ve been trying to learn Ruby on Rails over the past week or so, I decided that I might as well also try and learn Objective-C and that whole mess too.</p>
<p>Keeps life interesting.  But here&#8217;s the teaser shot taken right after the first time I actually deployed the radio app to my iPhone.</p>
<p><center><img class="aligncenter size-full wp-image-391" title="earbits-iphone-blog" src="http://iterat.ive.ly/wp-content/uploads/2010/09/earbits-iphone-blog.jpg" alt="" width="312" height="469" /></center></p>
<p>Hope to have a beta version done in a week or so, depending on API availability, and get it into the App Store sometime in September.</p>
]]></content:encoded>
			<wfw:commentRss>http://iterat.ive.ly/index.php/2010/09/01/coming-soon-earbits-radio-iphone-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A User Friend Relationship Model in&#160;Rails</title>
		<link>http://iterat.ive.ly/index.php/2010/08/31/a-user-friend-relationship-model-in-rails/</link>
		<comments>http://iterat.ive.ly/index.php/2010/08/31/a-user-friend-relationship-model-in-rails/#comments</comments>
		<pubDate>Wed, 01 Sep 2010 03:30:22 +0000</pubDate>
		<dc:creator>Christopher Gooley</dc:creator>
				<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[learning-ror]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[source]]></category>

		<guid isPermaLink="false">http://iterat.ive.ly/?p=341</guid>
		<description><![CDATA[In building my first Ruby on Rails app, I needed to create a facebook / social-networking style friend relationship between users. The simple requirements were that it the friendship should require approval (e.g. a friend request followed by an accept or ignore) and it should be lightweight (not using two records for a single relationship). [...]]]></description>
			<content:encoded><![CDATA[<p>In building my first Ruby on Rails app, I needed to create a facebook / social-networking style friend relationship between users. The simple requirements were that it the friendship should require approval (e.g. a friend request followed by an accept or ignore) and it should be lightweight (not using two records for a single relationship).</p>
<p>This method and code is inspired by two <a href="http://www.railsforum.com/viewtopic.php?id=16760">blog</a> <a href="http://railscasts.com/episodes/163-self-referential-association">posts</a>, which got me started but neither of which really fulfilled my complete requirement. The first used two records per friendship and the second was a twitter-style friend/follower without the approval process.</p>
<p>So, here I break down my Friendship model which hopefully you will find useful and/or insightful as a complete solution or a starting point for your own implementation.</p>
<p><span id="more-341"></span><br />
First step is to generate a new model that we&#8217;ll call Friendship.  A Friendship will connect two users, tracking who made the request, who the friend is, and whether the request has been approved. So we generate it like so:</p>
<pre class="brush:ruby; gutter:false; toolbar:false">$ script/generate model Friendship user_id:integer friend_id:integer approved:boolean</pre>
<p>This will create the db migration script and the app/models/friendship.rb file which we&#8217;re going to edit to include relationships to the User model. When first created, the Friendship model will be mostly empty so we need to add two lines.</p>
<pre class="brush:ruby">class Friendship &lt; ActiveRecord::Base
  belongs_to :user
  belongs_to :friend, :class_name =&gt; "User", :foreign_key =&gt; "friend_id"
end</pre>
<p>The first line is obviously creating a relationship to the User model, but the second line is a little more complex. It also needs to create a relationship to the User model (there isn&#8217;t a Friend model) but we want to refer to this as the friend. So we have to specify both the :class_name and the :foreign_key so that Rails knows how to hook up this :friend field to actual models.</p>
<p>Now that we have a Friendship, we need to configure the User model to allow for these self-referential relationship through the Friendship model. Before we hit the code, let&#8217;s walk through the concepts here that define the state of friendships and friends.</p>
<p>A friendship is a two-way relationship which is initiated by one user and approved by the other user. So, we have two states of a friendship (not-approved-yet or approved) and we have two directions of friendship relative to the current user: friendships requested <strong>by</strong> the current user (we&#8217;ll call these &#8220;direct&#8221; friendships), and friendships requested <strong>to</strong> the current user (we&#8217;ll call these &#8220;inverse&#8221; friendships).</p>
<p>So using this terminology, we have 4 possible states of Friendship:<br />
1) direct approved<br />
2) indirect approved<br />
3) direct not-approved<br />
4) indirect not-approved</p>
<p>States #1 and #2 are simply what we will be calling &#8220;friends&#8221; &#8211; they are approved relationships, no matter the direction.  Because we don&#8217;t care who requested the friendship once it&#8217;s approved, we will group these together.</p>
<p>State #3 is what we call &#8220;pending friends&#8221; &#8211; other users whom the current user has requested to be friends with and which are awaiting the other user&#8217;s approval. These are out of the control of the current user, and just waiting to be approved or rejected.</p>
<p>State #4 is what we&#8217;ll call &#8220;requested friends&#8221; &#8211; other users who have requested that the current user be their friend, and are awaiting the current user&#8217;s approval. These are the actionable items for the current user to approve. Ignoring a friend request simply deletes the non-approved Friendship, which is the Facebook method (doesn&#8217;t tell the other person they were rejected, but allows them to send another request if they want.)</p>
<p>Now that we have that groundwork, here is the User model:</p>
<pre class="brush:ruby;class-name:'nowrap'">class User &lt; ActiveRecord::Base
  [...]
  has_many :friendships
  has_many :inverse_friendships, :class_name =&gt; "Friendship", :foreign_key =&gt; "friend_id"
  has_many :direct_friends, :through =&gt; :friendships, :conditions =&gt; "approved = true", :source =&gt; :friend
  has_many :inverse_friends, :through =&gt; :inverse_friendships, :conditions =&gt; "approved = true", :source =&gt; :user

  has_many :pending_friends, :through =&gt; :friendships, :conditions =&gt; "approved = false", :foreign_key =&gt; "user_id", :source =&gt; :user
  has_many :requested_friendships, :class_name =&gt; "Friendship", :foreign_key =&gt; "friend_id", :conditions =&gt; "approved = false"

  def friends
    direct_friends | inverse_friends
  end
  [...]
end</pre>
<p>The first two lines are pretty self-explanatory as the first references our &#8220;direct&#8221; Friendships and the second our &#8220;inverse&#8221; Friendships which we&#8217;ll be using as the basis of all of our friend lists.  Lines 5 and 6 simply create our direct and inverse friend lists, only looking at friendships which have been approved. These are states #1 and #2 from our discussion above and are complete, approved bi-directional friends lists.</p>
<p>Line 8 here creates the list of pending friends (state #3 above) by looking for direct friendships which have not been approved.  Then finally in line 9 we handle state #4 which are the &#8220;requested friendship&#8221; waiting for us to approve them, by taking all the non-approved Friendships where the current user is the target of the request (which is why we specify the foreign_key of &#8220;friend_id&#8221;).</p>
<p>And finally, because it would be a hassle to deal with two lists of approved friends, we create a method to simply combine them under the name of &#8220;friends&#8221;, in lines 11-13.</p>
<p>That&#8217;s it! You should be able to create and manage facebook-style friend requests now.</p>
<p>I&#8217;m not going to cover creation of the Friendship controller here in this post, but I may in the future if people would find it helpful.  In short, the controller needs to handle just five actions: index, create, approve, ignore, delete.  In my implementation, all actions except for index are used only for ajax calls through link_to_remote, so they&#8217;re pretty lightweight.</p>
<p><strong>Updated</strong>: the direct_friends line in the User model above was incorrectly using &#8220;:source =&gt; :user&#8221; when it should be &#8220;:source =&gt; :friend&#8221; so that the returned models are the Friends you requested, not yourself the requestor.</p>
]]></content:encoded>
			<wfw:commentRss>http://iterat.ive.ly/index.php/2010/08/31/a-user-friend-relationship-model-in-rails/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Annoying Zune Behavior &#8211; Ordering &#8220;By&#160;Rating&#8221;</title>
		<link>http://iterat.ive.ly/index.php/2010/08/29/annoying-zune-behavior-ordering-by-rating/</link>
		<comments>http://iterat.ive.ly/index.php/2010/08/29/annoying-zune-behavior-ordering-by-rating/#comments</comments>
		<pubDate>Sun, 29 Aug 2010 19:27:28 +0000</pubDate>
		<dc:creator>Christopher Gooley</dc:creator>
				<category><![CDATA[quickie]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[zune]]></category>

		<guid isPermaLink="false">http://iterat.ive.ly/?p=332</guid>
		<description><![CDATA[I want to sort my music &#8220;By Rating&#8221; in the Zune media player software. This is natural. But what&#8217;s wrong with this track order here? Yeah, the software puts the songs which have ratings above the songs without ratings, which in itself isn&#8217;t a bad idea. But this means that if you just start playing [...]]]></description>
			<content:encoded><![CDATA[<p>I want to sort my music &#8220;By Rating&#8221; in the Zune media player software. This is natural. But what&#8217;s wrong with this track order here?</p>
<p><img class="aligncenter size-full wp-image-333" title="zune-rating-order" src="http://iterat.ive.ly/wp-content/uploads/2010/08/zune-rating-order.jpg" alt="" width="400" height="193" /></p>
<p>Yeah, the software puts the songs which <em>have <span style="font-style: normal;">ratings </span></em>above the songs without ratings, which in itself isn&#8217;t a bad idea. But this means that if you just start playing down the list of your favorite songs <strong>right after your favorite songs it&#8217;s going to play the songs you hate the most.</strong> Then it continues with the rest of your library in alphabetical order.</p>
<p>Come on, Microsoft&#8230; you can do better. Just put the most hated tracks at the bottom of the playlist when I sort by rating.</p>
]]></content:encoded>
			<wfw:commentRss>http://iterat.ive.ly/index.php/2010/08/29/annoying-zune-behavior-ordering-by-rating/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Deployment: Engine Yard or&#160;Heroku?</title>
		<link>http://iterat.ive.ly/index.php/2010/08/29/rails-deployment-engine-yard-or-heroku/</link>
		<comments>http://iterat.ive.ly/index.php/2010/08/29/rails-deployment-engine-yard-or-heroku/#comments</comments>
		<pubDate>Sun, 29 Aug 2010 17:46:53 +0000</pubDate>
		<dc:creator>Christopher Gooley</dc:creator>
				<category><![CDATA[question]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[learning-ror]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://iterat.ive.ly/?p=324</guid>
		<description><![CDATA[As I&#8217;m thinking about beta launching my first Rails app, I need to decide how to do the deploy.  Heroku and Engine Yard stand out as the most popular hosts, from what I see. Heroku also has a free option, which appeals to me.  Is one much better than the other? Long-term, I will probably [...]]]></description>
			<content:encoded><![CDATA[<p>As I&#8217;m thinking about beta launching my first Rails app, I need to decide how to do the deploy.  Heroku and Engine Yard stand out as the most popular hosts, from what I see. Heroku also has a free option, which appeals to me.  Is one much better than the other?</p>
<p>Long-term, I will probably host the app myself at my colo, but to keep things simple at first I don&#8217;t want to learn the intricacies of Rails hosting right now&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://iterat.ive.ly/index.php/2010/08/29/rails-deployment-engine-yard-or-heroku/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Chart: A Very Productive&#160;Evening</title>
		<link>http://iterat.ive.ly/index.php/2010/08/28/chart-a-productive-evening/</link>
		<comments>http://iterat.ive.ly/index.php/2010/08/28/chart-a-productive-evening/#comments</comments>
		<pubDate>Sat, 28 Aug 2010 11:22:17 +0000</pubDate>
		<dc:creator>Christopher Gooley</dc:creator>
				<category><![CDATA[asides]]></category>
		<category><![CDATA[cool stuff]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[graphic]]></category>
		<category><![CDATA[meta]]></category>

		<guid isPermaLink="false">http://iterat.ive.ly/?p=302</guid>
		<description><![CDATA[This is what learning a new language looks like: 50% time writing code, 25% time using chrome for research, and 10% time in firefox running and debugging the app. Clipped from RescueTime which is a fantastic freemium app that tracks everything you do on all of your computers and then does analysis of how you spend your time. Pretty [...]]]></description>
			<content:encoded><![CDATA[<p>This is what learning a new language looks like: <strong>50% </strong>time writing code, <strong>25%</strong> time using chrome for research, and <strong>10% </strong>time in firefox running and debugging the app.</p>
<p><img class="aligncenter" src="http://f.ive.ly/Aev.jpg" alt="" width="400" height="260" /></p>
<p>Clipped from <a href="http://rescuetime.com">RescueTime</a> which is a fantastic freemium app that tracks everything you do on all of your computers and then does analysis of how you spend your time.</p>
<p>Pretty cool, huh?</p>
]]></content:encoded>
			<wfw:commentRss>http://iterat.ive.ly/index.php/2010/08/28/chart-a-productive-evening/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning Rails – Day&#160;II</title>
		<link>http://iterat.ive.ly/index.php/2010/08/28/learning-rails-day-ii/</link>
		<comments>http://iterat.ive.ly/index.php/2010/08/28/learning-rails-day-ii/#comments</comments>
		<pubDate>Sat, 28 Aug 2010 10:50:06 +0000</pubDate>
		<dc:creator>Christopher Gooley</dc:creator>
				<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[learning-ror]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[whirlfood]]></category>

		<guid isPermaLink="false">http://iterat.ive.ly/?p=298</guid>
		<description><![CDATA[Well, I spent the second half of today (and &#62;4 hours at Farmer Boys) working on my Whirlfood project in Rails and made a surprising amount of progress.  Took some time to start to get used to the Rails methodology and the Ruby language syntax, but I think I&#8217;m in pretty good shape now. Got [...]]]></description>
			<content:encoded><![CDATA[<p>Well, I spent the second half of today (and &gt;4 hours at Farmer Boys) working on my Whirlfood project in Rails and made a surprising amount of progress.  Took some time to start to get used to the Rails methodology and the Ruby language syntax, but I think I&#8217;m in pretty good shape now.</p>
<p>Got to admit, I&#8217;m starting to like Rails for rapid development. After 2 days, I feel like I can build a simple web app almost as quickly as I can using C#.  Which completely amazes me.  Of course, there are lots of complex things and specialized functions that I still don&#8217;t know how to do in Rails, but still, I&#8217;m pretty stunned. In a good way.</p>
<p><span id="more-298"></span></p>
<p>I&#8217;ve gotten pretty comfortable using generators (a great idea) and then writing my own MVC stuff and doing custom db:migrate scripts to build models with complex relationships. Got the site set up using the <a href="http://github.com/binarylogic/authlogic">Authlogic</a> plugin to handle user sessions, registration and authentication.  Used <a href="http://oauth.rubyforge.org/">OAuth</a> to write the page flow system to get the tokens and then store them as part of the user model for future usage.  Learned <a href="http://ruby-doc.org/stdlib/libdoc/rexml/rdoc/index.html">REXML</a> to parse the responses from the <a href="http://groups.google.com/group/foursquare-api/web/api-documentation">Foursquare API</a> for user history, then created an import helper to turn Foursquare Venues into my internal Places model (while maintaining a strong reference to the foursquare id, to avoid duplicate creation).</p>
<p>Then I implemented the two major workhorse models used in Whirlfood &#8212; <em>visits</em> and <em>ratings</em>.  Visits were pretty easy, they are simply many-to-many model with a timestamp to associate <em>users</em> with <em>places</em> and times (the equivalent of Foursquare&#8217;s checkin).  Ratings were slightly more complex because they express the concept of &#8220;would you go back?&#8221; and are many-to-many between <em>users</em> and <em>places</em>, but don&#8217;t repeat every time the user visits.  Would be pretty annoying if you got asked if you like Subway every time you went there for lunch&#8230; so when the rating occurs, you&#8217;re only asked to rate places that you visited but have never rated.</p>
<p>Additionally, the ratings controller was a little different because it needed to handle AJAX saves and responses so that a full page of new places can be rated without page reloads.  Have to admit, the Rails way of doing this is pretty fantastic and foolproof&#8230;</p>
<p>Finally, I did some general controller workflow tweaking.  For instance, when your new history is imported there are two possibilities: a) you have new <em>places</em> to rate or b) nothing new to rate.  So depending on that case, the user will be redirected to the ratings controller or simply sent back home with a nice &#8220;nothing to do&#8221; notice. The flash[:notice] concept is another great idea that simplifies this very common function.</p>
<p>Also, in the import process, the import helper will only save new <em>places</em> if they fall into <em>categories</em> that the system knows about. This is because we want to filter out the noise of places like work, home and airports. To accomplish this, the Category model has aliases for each of our location providers (Foursquare, Gowalla, Facebook Places) that translate each of their proprietary category names into our common category system.  And if a category is unrecognized, we simply don&#8217;t import that place.</p>
<p>So, the interface is pretty ugly right now, but the core integration functionality is completed.  A new user can sign up, connect with Foursquare, import their checkin history, and rate their places.  I even added a neat google map to the places show view.</p>
<p>Next up: need to build <em>friends</em> and version one of the actual recommendation system.  And maybe spend a little time making the UI look nice. Then, I&#8217;ll need to spend some time working on the niceties like sending out a &#8220;Welcome to Whirlfood&#8221; email upon registration, for instance.</p>
]]></content:encoded>
			<wfw:commentRss>http://iterat.ive.ly/index.php/2010/08/28/learning-rails-day-ii/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>The&#160;Building-Learning Paradox</title>
		<link>http://iterat.ive.ly/index.php/2010/08/26/the-building-learning-paradox/</link>
		<comments>http://iterat.ive.ly/index.php/2010/08/26/the-building-learning-paradox/#comments</comments>
		<pubDate>Thu, 26 Aug 2010 20:08:12 +0000</pubDate>
		<dc:creator>Christopher Gooley</dc:creator>
				<category><![CDATA[software]]></category>
		<category><![CDATA[innovation]]></category>
		<category><![CDATA[learning]]></category>

		<guid isPermaLink="false">http://iterat.ive.ly/?p=284</guid>
		<description><![CDATA[If you want to learn a new langauge or framework you need a good project idea as the basis for what you&#8217;re building as you learn. But if you have a good project idea to work on, you want to get it to market as soon as possible. I present to you The Building-Learning Paradox. [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to learn a new langauge or framework you need a good project idea as the basis for what you&#8217;re building as you learn. But if you have a good project idea to work on, you want to get it to market as soon as possible. I present to you The Building-Learning Paradox.</p>
<p>I conjecture that this paradox is the reason that highly motivated people tend to learn in smaller incremental steps rather than diving head-first into a new technology.  It&#8217;s basically impossible to satisfy both these main motivators at once.  Not 100% sure what I&#8217;m going to do for this project I&#8217;m working on right now, but I think I&#8217;m going to sacrifice speed in order to learn something new. We&#8217;ll see if I can keep that up for very long.</p>
<p>How do you deal with this paradox? I&#8217;m curious.</p>
]]></content:encoded>
			<wfw:commentRss>http://iterat.ive.ly/index.php/2010/08/26/the-building-learning-paradox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning Rails – Day&#160;I</title>
		<link>http://iterat.ive.ly/index.php/2010/08/23/learning-rails-day-i/</link>
		<comments>http://iterat.ive.ly/index.php/2010/08/23/learning-rails-day-i/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 01:30:22 +0000</pubDate>
		<dc:creator>Christopher Gooley</dc:creator>
				<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[learning-ror]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://iterat.ive.ly/?p=272</guid>
		<description><![CDATA[I&#8217;ve been reading up a bit on Ruby and think I have a passable handle on the syntax.  Also studied the structure of Rails apps.  So now it&#8217;s time to actually build something to actually learn it.  And because I have no patience for more Hello World examples, I&#8217;m going to build something actually useful. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been reading up a bit on <a href="http://www.ruby-lang.org/en/">Ruby</a> and think I have a passable handle on the syntax.  Also studied the structure of <a href="http://guides.rubyonrails.org/index.html">Rails</a> apps.  So now it&#8217;s time to actually build something to actually learn it.  And because I have no patience for more Hello World examples, I&#8217;m going to build something actually useful.</p>
<p>Only problem is that I don&#8217;t have any tiny project ideas right now.  So I&#8217;m going to re-work an existing idea and build a social restaurant recommendation site, based on my previous (poorly-named) <a href="/index.php/2008/07/13/edaah-the-social-food-recommendation-site/">Edahh project</a>.  If it turns out well, it might just be the basis for a re-launch of that service.</p>
<p>But let&#8217;s not get ahead of ourselves.  First things first:<br />
<code><br />
$ rails whirlfood -d mysql<br />
</code></p>
<p>And the adventure begins.</p>
]]></content:encoded>
			<wfw:commentRss>http://iterat.ive.ly/index.php/2010/08/23/learning-rails-day-i/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
