<?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>lifecoding.com Blog &#187; Rails</title>
	<atom:link href="http://lifecoding.com/blog/index.php/category/rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://lifecoding.com/blog</link>
	<description>(define (life-coding life code) (organize life (using code)))</description>
	<lastBuildDate>Wed, 11 Jun 2008 03:29:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>RailsconfEurope 2007</title>
		<link>http://lifecoding.com/blog/2007/10/18/railsconfeurope-2007/</link>
		<comments>http://lifecoding.com/blog/2007/10/18/railsconfeurope-2007/#comments</comments>
		<pubDate>Thu, 18 Oct 2007 19:57:51 +0000</pubDate>
		<dc:creator>Trotter Cashion</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://lifecoding.com/blog/?p=34</guid>
		<description><![CDATA[I&#8217;m a little late in mentioning this, but I recently spoke at RailsconfEurope about Rails Refactoring. It was a tutorial talk, and I thought that it went very well. I think the presentation is up on O&#8217;Reilly somewhere; I&#8217;ll link if I can find it.
Overall, the conference was really good. Berlin is an amazing city [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a little late in mentioning this, but I recently spoke at <a href="http://www.railsconfeurope.com/">RailsconfEurope</a> about <a href="http://www.railsconfeurope.com/cs/railseurope2007/view/e_sess/14232">Rails Refactoring</a>. It was a tutorial talk, and I thought that it went very well. I think the presentation is up on O&#8217;Reilly somewhere; I&#8217;ll link if I can find it.</p>
<p>Overall, the conference was really good. Berlin is an amazing city and the majority of the talks were really good. Of special note were the ones by <a href="http://drnicwilliams.com/">Dr. Nic</a>, <a href="http://nubyonrails.com/">Topfunky</a>, and <a href=http://blog.fallingsnow.net/">Evan Phoenix</a>. Their talks about ruby magic, css generation, and rubinius were really well done.</p>
]]></content:encoded>
			<wfw:commentRss>http://lifecoding.com/blog/2007/10/18/railsconfeurope-2007/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nyc.rb turns 3!</title>
		<link>http://lifecoding.com/blog/2007/02/20/nycrb-turns-3/</link>
		<comments>http://lifecoding.com/blog/2007/02/20/nycrb-turns-3/#comments</comments>
		<pubDate>Tue, 20 Feb 2007 19:54:27 +0000</pubDate>
		<dc:creator>Trotter Cashion</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[nyc.rb]]></category>
		<category><![CDATA[refactoring]]></category>

		<guid isPermaLink="false">http://lifecoding.com/blog/?p=32</guid>
		<description><![CDATA[Well, last Tuesday nyc.rb turned three years old. Of course, we were not content with just turning three, so we decided to start taping our presentations also (By we, I mean me, because I have a video camera and turned it on). Francis gave a testing clinic, while yours truly gave a talk on refactoring. [...]]]></description>
			<content:encoded><![CDATA[<p>Well, last Tuesday nyc.rb turned three years old. Of course, we were not content with just turning three, so we decided to start taping our presentations also (By we, I mean me, because I have a video camera and turned it on). Francis gave a testing clinic, while yours truly gave a talk on refactoring. Both talks are available on Motionbox (the Rails video site at which I work) at <a href="http://www.motionbox.com/playlist/show/4a9fddb51f1cc4">this playlist</a>.</p>
<p>To make things easier for you, I&#8217;ve also embeded the videos after the jump. Francis&#8217;s video is first with mine second. Sorry for the occasional fuzzy video quality, I&#8217;m still not good at filming presentations.</p>
<p><span id="more-32"></span><br />
<embed src="http://www.motionbox.com/external/player/id%3D4a97d7b31e19c4" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" width="425" height="460"></embed></p>
<p></p>
<p><embed src="http://www.motionbox.com/external/player/id%3D4a97dabe1d1ac4" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" width="425" height="460"></embed></p>
]]></content:encoded>
			<wfw:commentRss>http://lifecoding.com/blog/2007/02/20/nycrb-turns-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CRUD Presentation</title>
		<link>http://lifecoding.com/blog/2006/07/25/crud-presentation/</link>
		<comments>http://lifecoding.com/blog/2006/07/25/crud-presentation/#comments</comments>
		<pubDate>Wed, 26 Jul 2006 03:32:48 +0000</pubDate>
		<dc:creator>Trotter Cashion</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[CRUD]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://lifecoding.com/blog/?p=31</guid>
		<description><![CDATA[The slides from my CRUD Presentation to nyc.rb are now up. Lee Nussbaum snagged the audio, so I&#8217;ll sync that up over the next few days and post that too.  If you&#8217;ve seen DHH&#8217;s presentation, this one is pretty much the same thing. In fact, many of the slides look fairly similar. I hope [...]]]></description>
			<content:encoded><![CDATA[<p>The slides from my <a href="http://lifecoding.com/presentations/CRUD_presentation.pdf">CRUD Presentation</a> to <a href="http://nycruby.com">nyc.rb</a> are now up. Lee Nussbaum snagged the audio, so I&#8217;ll sync that up over the next few days and post that too.  If you&#8217;ve seen DHH&#8217;s presentation, this one is pretty much the same thing. In fact, many of the slides look fairly similar. I hope you don&#8217;t mind, DHH :-).</p>
]]></content:encoded>
			<wfw:commentRss>http://lifecoding.com/blog/2006/07/25/crud-presentation/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How to Make Pound And SSL Play Nice With OS X</title>
		<link>http://lifecoding.com/blog/2006/06/09/how-to-make-pound-and-ssl-play-nice-with-os-x/</link>
		<comments>http://lifecoding.com/blog/2006/06/09/how-to-make-pound-and-ssl-play-nice-with-os-x/#comments</comments>
		<pubDate>Fri, 09 Jun 2006 22:23:31 +0000</pubDate>
		<dc:creator>Trotter Cashion</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[SysAdmin]]></category>
		<category><![CDATA[Utilities]]></category>

		<guid isPermaLink="false">http://lifecoding.com/blog/?p=29</guid>
		<description><![CDATA[Though building sites with ssl is cool and gives your users a sense of security, configuring a webserver with ssl can be a royal pain. Thankfully, there&#8217;s pound.  Pound is a &#8220;is a reverse proxy, load balancer and HTTPS front-end for Web server(s).&#8221;
Pound is dead simple to setup and configure. Unfortunately, the darwin port [...]]]></description>
			<content:encoded><![CDATA[<p>Though building sites with ssl is cool and gives your users a sense of security, configuring a webserver with ssl can be a royal pain. Thankfully, there&#8217;s pound.  <a href="">Pound</a> is a &#8220;is a reverse proxy, load balancer and HTTPS front-end for Web server(s).&#8221;</p>
<p>Pound is dead simple to setup and configure. Unfortunately, the darwin port for pound is old and does not work. So this guide will help you build pound on your own. Besides, everyone feels cooler after compiling that hot fire. Click on for the steps.</p>
<ol>
<span id="more-29"></span></p>
<li>Open terminal.</li>
<li>Install zlib</li>
<pre>
mkdir ~/temp
curl -O http://www.zlib.net/zlib-1.2.3.tar.gz
tar xzvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure --prefix=/usr/local --shared
make
sudo make install
</pre>
<li>Install openssl</li>
<pre>
curl -O http://www.openssl.org/source/openssl-0.9.8b.tar.gz
tar xzvf openssl-0.9.8b.tar.gz
cd openssl-0.9.8b
./config -L/usr/local/lib --openssldir=/usr/local/etc/openssl \\
    zlib no-asm no-krb5 shared
make
sudo make install
</pre>
<li>Install Pound 2.0 or greater</li>
<pre>
curl -O http://www.apsis.ch/pound/Pound-2.0.tgz
tar xzvf Pound-2.0.tgz
cd Pound-2.0
sed "s/-o bin -g bin //g" < Makefile.in > Makefile.in.new
mv Makefile.in.new Makefile.in  # Hit y to override any restrictions
./configure --with-ssl=/usr/local/etc/openssl/ --prefix=/usr/local
make
sudo make install
</pre>
<li>Generate an ssl certificate.</li>
<pre>
cd /usr/local/etc
</pre>
<p>You can put the next line in ~/.bash_profile if you want openssl available everytime you open the terminal.</p>
<pre>
export PATH="/usr/local/etc/openssl/bin:$PATH"
sudo openssl/bin/openssl req -x509 -newkey rsa:1024 -keyout our_cert.pem \\
    -out our_cert.pem -days 365 -nodes
</pre>
<p>Fill out the required information to generate the ssl certificate.</p>
<li>Create a pound.cfg file.</li>
<pre>
cd /usr/local/etc # You should already be here
</pre>
<p>This next piece uses a trick called a heredoc. Instead of copying and pasting the below command into terminal, you could also just copy and paste the text into pound.cfg in /usr/local/etc/pound.cfg</p>
<pre>
cat &gt; ~/tmp_file &lt;&lt;EOF
ListenHTTP
  Address 0.0.0.0
  Port    80
  Service
    BackEnd
      Address 127.0.0.1
      Port    3000
    End
  End
End

ListenHTTPS
  Address 0.0.0.0
  Port    443
  Cert    "/usr/local/etc/our_cert.pem"
  # pass along https hint
  AddHeader "X-Forwarded-Proto: https"
  HeadRemove "X-Forwarded-Proto"
  Service
    BackEnd
      Address 127.0.0.1
      Port    3000
    End
  End
End
EOF
sudo mv ~/tmp_file ./pound.cfg
</pre>
<li>Make sure that pound works.</li>
<pre>
pound -v -c
</pre>
<p>You should see Config file /usr/local/etc/pound.cfg is OK.<br />
If not, make sure that you copied your config file correctly<br />
using &#8216;cat pound.cfg&#8217; to view what is in the file.</p>
<li>Turn off apache (assuming it&#8217;s running).</li>
<pre>sudo apachectl stop</pre>
<li>Turn on pound.</li>
<pre>sudo pound -v</pre>
<li>Start mongrel/webrick/lighty.</li>
<pre>
cd ~/work/my_killer_app
mongrel_rails start # Or ruby script/server (if you're still on lighty/webrick)
</pre>
<li>Marvel at your wonderous creation by pointing your browser to http://localhost/ or https://localhost/</li>
</ol>
<p>TODO (feel free to do these and post how to do them in the comments):
<ul>
<li>Make pound start when the computer loads.</li>
<li>Use darwin ports to install zlib and openssl, but not pound.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://lifecoding.com/blog/2006/06/09/how-to-make-pound-and-ssl-play-nice-with-os-x/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Use Session Sparingly (or The Benefits of Flash)</title>
		<link>http://lifecoding.com/blog/2006/06/05/use-session-sparingly-or-the-benefits-of-flash/</link>
		<comments>http://lifecoding.com/blog/2006/06/05/use-session-sparingly-or-the-benefits-of-flash/#comments</comments>
		<pubDate>Mon, 05 Jun 2006 14:52:37 +0000</pubDate>
		<dc:creator>Trotter Cashion</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://lifecoding.com/blog/?p=26</guid>
		<description><![CDATA[As tempting as it is to use it for everything, the rails session should be used sparingly.  In reading through the code for my current project, I noticed that we are using the session for storing return urls and query strings when doing login redirects.  This is bad.

Let&#8217;s look at an example of [...]]]></description>
			<content:encoded><![CDATA[<p>As tempting as it is to use it for everything, the rails session should be used sparingly.  In reading through the code for my current project, I noticed that we are using the session for storing return urls and query strings when doing login redirects.  This is <strong>bad</strong>.</p>
<p><span id="more-26"></span></p>
<p>Let&#8217;s look at an example of user behavior to see why:</p>
<ol>
<li>The user types http://superapp.com/account/logged_in into their browser.</li>
<li>This url is protected to the user is redirected to http://superapp.com/account/login and /account/logged_in is stored in session[:jump_to].</li>
<li>The user gets confused, lost, or just behaves like a typical user and navigates somewhere else.</li>
<li>Sometime later, the user goes to http://superapp.com/account/login and logs in.</li>
<li>The user is taken to &#8216;/account/logged_in&#8217; instead of &#8216;account/welcome&#8217;.  The user is confused.</li>
</ol>
<p>Though user confusion on its own is bad, this still may not seem like much of a problem.  So the user gets redirected to a different url than usual, how bad is that?  In the app I&#8217;m currently working on, this behavior can be very bad. Depending on how the user is coming to the site and logging in, a bad return url can cause significant confusion to the user.</p>
<p>To fix this problem, the flash should be used instead of the session.  Though the flash technically is the session, it is automatically cleared after each request.  This prevents time sensitive data such as redirection urls from being stored longer than necessary and guarantees that you do not confuse your user with seemingly different points of entry on login.</p>
]]></content:encoded>
			<wfw:commentRss>http://lifecoding.com/blog/2006/06/05/use-session-sparingly-or-the-benefits-of-flash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby Reminder: Array Subtraction</title>
		<link>http://lifecoding.com/blog/2006/06/05/ruby-reminder-array-subtraction/</link>
		<comments>http://lifecoding.com/blog/2006/06/05/ruby-reminder-array-subtraction/#comments</comments>
		<pubDate>Mon, 05 Jun 2006 14:46:52 +0000</pubDate>
		<dc:creator>Trotter Cashion</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Languages]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://lifecoding.com/blog/?p=27</guid>
		<description><![CDATA[Just a reminder when working with arrays of objects generated with Active Record.

[Model.find(1), Model.find(2), Model.find(3)] -
  [Model.find(1)] != [Model.find(2), Model.find(3)]

This does not behave as you would expect, because array subtraction compares elements on their object ids. Each find generates a new object, with a new id, so subtraction does not work. To get the [...]]]></description>
			<content:encoded><![CDATA[<p>Just a reminder when working with arrays of objects generated with Active Record.</p>
<pre>
[Model.find(1), Model.find(2), Model.find(3)] -
  [Model.find(1)] != [Model.find(2), Model.find(3)]
</pre>
<p>This does not behave as you would expect, because array subtraction compares elements on their object ids. Each find generates a new object, with a new id, so subtraction does not work. To get the behavior desired, do this instead:</p>
<pre>
to_be_removed = [Model.find(1)].map{|m| m.id}
[Model.find(1), Model.find(2), Model.find(3)].
  delete_if{|m| to_be_removed.include?(m.id)}
</pre>
<p>It&#8217;s not as beautiful, but it gets the job done.</p>
]]></content:encoded>
			<wfw:commentRss>http://lifecoding.com/blog/2006/06/05/ruby-reminder-array-subtraction/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

