<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Benjamin Oakes</title>
	
	<link>http://www.benjaminoakes.com</link>
	<description />
	<lastBuildDate>Thu, 01 Dec 2011 13:55:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/BenjaminOakes" /><feedburner:info uri="benjaminoakes" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>autoload in Ruby 1.8 and Rails</title>
		<link>http://feedproxy.google.com/~r/BenjaminOakes/~3/Q7MXgzbNa6s/</link>
		<comments>http://www.benjaminoakes.com/2011/12/01/autoload-in-ruby-1-8-libraries/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 13:54:47 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.benjaminoakes.com/?p=140</guid>
		<description><![CDATA[Just a PSA from a recent Ruby discussion: Ruby&#8217;s autoload works fine if you&#8217;re using it in a gem that&#8217;s loaded once (and need to use it on Ruby 1.8, vs. require_relative in Ruby 1.9+), but if autoload is used in a collection of Ruby classes or modules in a folder that&#8217;s in the Rails [...]]]></description>
			<content:encoded><![CDATA[<p>Just a PSA from a recent Ruby discussion:</p>
<p>Ruby&#8217;s <code>autoload</code> works fine if you&#8217;re using it in a gem that&#8217;s loaded <b>once</b> (and need to use it on Ruby 1.8, vs. <code>require_relative</code> in Ruby 1.9+), but if <code>autoload</code> is used in a collection of Ruby classes or modules in a folder that&#8217;s in the Rails load path, then it&#8217;s probably not a good idea.  You&#8217;ll get unexpected reloading behavior, at a minimum.  That applies to submodules too, of course.</p>
<p>In general, you don&#8217;t want to mess with <code>$LOAD_PATH</code>, which was a fairly common practice in 1.8.  That&#8217;s largely gone away in 1.9 with the advent of <code>require_relative</code>, but many gems need to be backwards compatible.  In Ruby 1.8, you can always futz around with <code>__FILE__</code>, but that gets messy as well.</p>
<img src="http://feeds.feedburner.com/~r/BenjaminOakes/~4/Q7MXgzbNa6s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.benjaminoakes.com/2011/12/01/autoload-in-ruby-1-8-libraries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.benjaminoakes.com/2011/12/01/autoload-in-ruby-1-8-libraries/</feedburner:origLink></item>
		<item>
		<title>Blocking migration creation in Rails</title>
		<link>http://feedproxy.google.com/~r/BenjaminOakes/~3/1soMm_an8aA/</link>
		<comments>http://www.benjaminoakes.com/2011/11/29/blocking-migration-creation-in-rails/#comments</comments>
		<pubDate>Tue, 29 Nov 2011 16:40:16 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.benjaminoakes.com/?p=137</guid>
		<description><![CDATA[We have a project that accesses a shared database. To prevent problems (and confusion) we wanted to block the creation of migrations in the &#8220;secondary&#8221; applications so that there was one authoritative place for migrations to live. It&#8217;s easy to accomplish in a simple way. If you&#8217;ve never made any migrations in the secondary application, [...]]]></description>
			<content:encoded><![CDATA[<p>We have a project that accesses a shared database.  To prevent problems (and confusion) we wanted to block the creation of migrations in the &#8220;secondary&#8221; applications so that there was one authoritative place for migrations to live.</p>
<p>It&#8217;s easy to accomplish in a simple way.</p>
<p>If you&#8217;ve never made any migrations in the secondary application, just do this:</p>
<pre><code>$ echo "NOTE Please do not make migrations in this project.  They should all live in _primary app_." > db/migrate
</code></pre>
<p>That way, when you run <code>rails g migration foo</code>, you&#8217;ll get this:</p>
<pre><code>$ rails g migration foo
      invoke  active_record
      create    db/migrate/20111129162804_foo.rb
[...]/ruby-1.9.2-p180/lib/ruby/1.9.1/fileutils.rb:243:in `mkdir': File exists - [...]/db/migrate (Errno::EEXIST)
</code></pre>
<p>When you try to <code>cd</code> into that directory, you&#8217;ll get this:</p>
<pre><code>$ cd db/migrate
bash: cd: db/migrate: Not a directory
</code></pre>
<p>After you get over the initial &#8220;wha?&#8221; reaction, you&#8217;ll look at <code>db/migrate</code> and see the message:</p>
<pre><code>$ cat db/migrate
NOTE Please do not make migrations in this project.  They should all live in _primary app_.
</code></pre>
<p>Pretty nice, right?</p>
<img src="http://feeds.feedburner.com/~r/BenjaminOakes/~4/1soMm_an8aA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.benjaminoakes.com/2011/11/29/blocking-migration-creation-in-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.benjaminoakes.com/2011/11/29/blocking-migration-creation-in-rails/</feedburner:origLink></item>
		<item>
		<title>Using Heroku with an external MySQL database</title>
		<link>http://feedproxy.google.com/~r/BenjaminOakes/~3/vf9MzuiIRfM/</link>
		<comments>http://www.benjaminoakes.com/2011/11/21/using-heroku-with-an-external-mysql-database/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 20:33:10 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[contribution]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[external]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[heroku]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[oss]]></category>

		<guid isPermaLink="false">http://www.benjaminoakes.com/?p=136</guid>
		<description><![CDATA[We recently had a need to use Heroku with an external MySQL database. Thankfully, there was already a gem that solved the problem. However, it didn&#8217;t have that much by the way of documentation, so I wrote this up and contributed it to the author. Also, I added X.509 support, which we required. NOTE: After [...]]]></description>
			<content:encoded><![CDATA[<p>We recently had a need to use Heroku with an external MySQL database.  Thankfully, there was already a <a href="https://github.com/nbudin/heroku_external_db">gem</a> that solved the problem.  However, it didn&#8217;t have that much by the way of documentation, so I wrote this up and contributed it to the author.  Also, I added X.509 support, which we required.</p>
<hr />
<p><b>NOTE:</b> After my pull requests are merged, you should look to <a href="https://github.com/nbudin/heroku_external_db">the main repository&#8217;s README</a> which has a copy of the below.</p>
<hr />
<h4>Example: MySQL with a CA Certificate</h4>
<p>In this example, we are setting up a connection to an external MySQL server using the default initializer.</p>
<p>What we have:</p>
<ul>
<li>
<p>A CA certificate called <tt>ca-cert.pem</tt></p>
</li>
<li>
<p>A database is available at mysql://username:password@server/dbname (where <tt>username</tt>, <tt>password</tt>, <tt>server</tt>, and <tt>dbname</tt> are the appropriate values for our server)</p>
</li>
<li>
<p>Other security, e.g. firewalls.  Please make sure to open the appropriate ports and grant the necessary access for your database to be available externally.  Further discussion is outside the scope of this document, but for accessing EC2, you might start at <a href="http://devcenter.heroku.com/articles/external-services">devcenter.heroku.com/articles/external-services</a>.</p>
</li>
</ul>
<p>First, we configure Heroku with the appropriate environment variables:</p>
<pre># You may have to specify the app name or remote name here via --app or --remote, respectively
heroku config:add EXTERNAL_DATABASE_CA='ca-cert.pem'
heroku config:add EXTERNAL_DATABASE_URL='mysql://username:password@server/dbname'</pre>
<p>By default, <tt>heroku_external_db</tt> looks for the CA cert in<br />
<tt>config/ca</tt>, so we need to commit it:</p>
<pre>mkdir -p config/ca
cp path/to/ca-cert.pem config/ca
git add config/ca
git commit -v # Using -v since we want to make sure the contents are what we expect (e.g. not a private key)</pre>
<p>Additionally, we need the <tt>mysql</tt> gem in our Gemfile since we are setting up a MySQL server:</p>
<pre>echo "gem 'mysql', '~&gt; 2.8.1'" &gt;&gt; Gemfile
bundle install # Need Gemfile.lock too</pre>
<p>Keep in mind that Heroku installs its own <tt>database.yml</tt> for Rails apps and we have to install <tt>pg</tt> as well.  Unfortunately, shared databases are mandatory (but are free).</p>
<pre>$ heroku addons:remove shared-database:5mb
-----&gt; Removing shared-database:5mb from our-app... failed
 !     Shared databases cannot be removed</pre>
<p>PostgreSQL may still be useful to you if, for example, you want to have feature toggles in a local database, but the main data kept externally.  However in our case, it also means all developers will need MySQL and PostgreSQL running locally, which is unfortunate.</p>
<p>One workaround is only installing <tt>pg</tt> in production:</p>
<pre># File: Gemfile

# *Only* needed on production.
group :production do
  gem 'pg', '~&gt; 0.11.0' # Regardless of whether you plan to use the database or not, Heroku requires you have 'pg' installed.
end</pre>
<p>Then <tt>bundle</tt> like so:</p>
<pre>$ bundle install --without production</pre>
<p>With our gems updated, commit:</p>
<pre>git commit -av # Commit Gemfile and Gemfile.lock</pre>
<p>Another option may be overriding <tt>database.yml</tt> somehow, although it would add complexity.  For more info, please see <a href="http://stackoverflow.com/questions/4204724/strategies-for-overriding-database-yml">stackoverflow.com/questions/4204724/strategies-for-overriding-database-yml</a>.</p>
<p>With our dependencies out of the way, we can move on to testing the connection.</p>
<p>If you are making a new application, you may wish to have a simple MVC for testing that the connection works.  E.g., for a blog style application with posts do:</p>
<pre>rails generate scaffold post
# NOTE you probably want to change the default "Post.all" to "Post.limit(5)" or something similar
git add .
git commit # ...
# Don't forget to set a default route, etc.</pre>
<p>With all these changes committed, we can deploy to our Heroku app:</p>
<pre>git push heroku master # Your remote may be different</pre>
<p>Now, since we are connecting to an existing database, we don’t need to run any migrations.  (Keep in mind that when sharing a database, it is best to have one authoritative source for migrations to live.)  If in your situation you’re creating a new database, you may need to do that, run migrations, seed the database, etc at this point.</p>
<p>Open <a href="http://our-app.heroku.com">our-app.heroku.com</a> and we should see our data.  If you happen to run into a problem, please check the logs first:</p>
<pre>heroku logs --tail # Again, you may need to specify an app</pre>
<p>If you are having a problem, a good starting point is double checking your passwords, usernames, security settings, etc.</p>
<h4>Example: MySQL with X.509</h4>
<p>The process is very much the same as the above example, except two extra environment variables and files are required.  Below are the extra steps.</p>
<p>What we have:</p>
<ul>
<li>
<p>A CA certificate called <tt>ca-cert.pem</tt></p>
</li>
<li>
<p>A client certificate called <tt>client-cert.pem</tt></p>
</li>
<li>
<p>A client key called <tt>client-key.pem</tt></p>
</li>
</ul>
<p>First, we configure Heroku with the appropriate environment variables:</p>
<pre>heroku config:add EXTERNAL_DATABASE_CA='ca-cert.pem'
heroku config:add EXTERNAL_DATABASE_CERT='client-cert.pem'
heroku config:add EXTERNAL_DATABASE_KEY='client-key.pem'</pre>
<p>By default, <tt>heroku_external_db</tt> looks for the files in <tt>config/ca</tt>, so we need to commit them:</p>
<pre>mkdir -p config/ca
cp path/to/ca-cert.pem path/to/client-cert.pem path/to/client-key.pem config/ca
git add config/ca
git commit</pre>
<p>The rest of the process is the same as in “MySQL with a CA Certificate”.</p>
<img src="http://feeds.feedburner.com/~r/BenjaminOakes/~4/vf9MzuiIRfM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.benjaminoakes.com/2011/11/21/using-heroku-with-an-external-mysql-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.benjaminoakes.com/2011/11/21/using-heroku-with-an-external-mysql-database/</feedburner:origLink></item>
		<item>
		<title>RubyConf 2011</title>
		<link>http://feedproxy.google.com/~r/BenjaminOakes/~3/NUhLgNl40Hw/</link>
		<comments>http://www.benjaminoakes.com/2011/10/03/rubyconf-2011/#comments</comments>
		<pubDate>Mon, 03 Oct 2011 14:13:37 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[neworleans]]></category>
		<category><![CDATA[rubyconf]]></category>

		<guid isPermaLink="false">http://www.benjaminoakes.com/?p=134</guid>
		<description><![CDATA[RubyConf 2011 was a blast. It was great to meet other Rubyists, get a ton of T-shirts (no really, I got 8 or so), and talk Aaron Patterson into giving Jonathan Magen a special message. If you weren&#8217;t able to go, I pushed my notes up to a public GitHub wiki. A couple others from [...]]]></description>
			<content:encoded><![CDATA[<p><img alt="RubyConf 2011 logo" src="http://confreaks.net/system/events/logos/47/rubyconf2011-logo-small-original.jpg?1317327959" style="width: 100%" /></p>
<p>RubyConf 2011 was a blast.  It was great to meet other Rubyists, get a ton of T-shirts (no really, I got 8 or so), and talk Aaron Patterson into giving Jonathan Magen a <a href="http://www.youtube.com/watch?v=q8PPKWpLmkw">special message</a>.</p>
<p>If you weren&#8217;t able to go, I pushed my notes up to a <a href="https://github.com/benjaminoakes/rubyconf2011/wiki">public GitHub wiki</a>.  A couple others from <a href="http://www.hedgeye.com">Hedgeye</a> are adding their notes as well, so with those (plus the <a href="http://confreaks.net/events/rubyconf2011">Confreaks videos</a> when those guys finally have access to a reliable Internet connection), it&#8217;s almost like you were there.</p>
<img src="http://feeds.feedburner.com/~r/BenjaminOakes/~4/NUhLgNl40Hw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.benjaminoakes.com/2011/10/03/rubyconf-2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.benjaminoakes.com/2011/10/03/rubyconf-2011/</feedburner:origLink></item>
		<item>
		<title>ActiveRecord::ConnectionNotEstablished in Rails 3.1 on Heroku</title>
		<link>http://feedproxy.google.com/~r/BenjaminOakes/~3/GvvQprNiX1M/</link>
		<comments>http://www.benjaminoakes.com/2011/09/15/activerecordconnectionnotestablished-in-rails-3-1-on-heroku/#comments</comments>
		<pubDate>Thu, 15 Sep 2011 15:03:50 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Rails 3.1.0]]></category>

		<guid isPermaLink="false">http://www.benjaminoakes.com/?p=132</guid>
		<description><![CDATA[We have a simple application that doesn&#8217;t have an ActiveRecord dependency. It&#8217;s deployed to Heroku, and it&#8217;s been working fine on Rails 3.0.x since April 2011. We knew we weren&#8217;t using ActiveRecord for database connectivity, but we let it be, since it wasn&#8217;t causing any issues. When upgrading to Rails 3.1, we found that every [...]]]></description>
			<content:encoded><![CDATA[<p>We have a simple application that doesn&#8217;t have an <code>ActiveRecord</code> dependency.  It&#8217;s deployed to Heroku, and it&#8217;s been working fine on Rails 3.0.x since April 2011.  We knew we weren&#8217;t using <code>ActiveRecord</code> for database connectivity, but we let it be, since it wasn&#8217;t causing any issues.</p>
<p>When upgrading to Rails 3.1, we found that every single page would give <code>ActiveRecord::ConnectionNotEstablished</code> on our staging environment on Heroku.  The same error didn&#8217;t happen in development.  Although we might have been able to get <code>gem 'pg'</code> set up and working, we really didn&#8217;t need an ActiveRecord dependency at all.</p>
<p>I found <a href="http://stackoverflow.com/questions/2212709/remove-activerecord-in-rails-3-beta">part of a solution on StackOverflow</a>, but it needed a little tweaking for Rails 3.1.0.</p>
<pre><code># File: config/application.rb

# Pick the frameworks you want:
# require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "sprockets/railtie"
require "rails/test_unit/railtie"
</code></pre>
<p>That&#8217;s what Rails 3.1.0 generates when running <code>rails new myproject --skip-active-record</code>.  (Note that <code>require "active_record/railtie"</code> is commented out.)  This solved our <code>ActiveRecord::ConnectionNotEstablished</code> problem, but gave us a few others, namely:</p>
<ul>
<li>Fixtures</li>
<li><code>ActiveRecord::RecordNotFound</code> (used for 404s)</li>
</ul>
<h4>Fixtures</h4>
<p>There&#8217;s some normal stuff to get rid of in terms of <code>spec_helper.rb</code> and/or <code>test_helper.rb</code>.  Here&#8217;s an example:</p>
<pre><code># File spec/spec_helper.rb

# # If you're not using ActiveRecord, or you'd prefer not to run each of your
# # examples within a transaction, remove the following line or assign false
# # instead of true.
# config.use_transactional_fixtures = true
</code></pre>
<p>You may have others.  <a href="https://rubygems.org/gems/tarantula">Tarantula</a> had to be adjusted for us, for example.</p>
<h4><code>ActiveRecord::RecordNotFound</code></h4>
<p><code>ActiveRecord::RecordNotFound</code>, however, was an interesting problem.  Everything worked fine without <code>ActiveRecord</code> except the places where we were using <code>ActiveRecord::RecordNotFound</code> to give a <code>HTTP 404</code> to the user agent.  That seems strange in a lot of ways, because a <code>404</code> shouldn&#8217;t have anything to do with your chosen ORM.  My first intuition was to do <code>require 'active_record/errors'</code> (see also the <a href="http://api.rubyonrails.org/classes/ActiveRecord/RecordNotFound.html">Rails docs</a>), but that caused problems with assumptions in <code>'rspec/rails'</code>.</p>
<p>Right now, the below is what we ended up with:</p>
<pre><code># File: config/application.rb

# Pick the frameworks you want:
# require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "sprockets/railtie"
require "rails/test_unit/railtie"

# For errors like ActiveRecord::RecordNotFound
require "active_record"
</code></pre>
<p>Our automated tests (Rspec, integration tests, Tarantula, Selenium, etc) all pass with it and we no longer get <code>ActiveRecord::ConnectionNotEstablished</code>, but we still have an ActiveRecord dependency I don&#8217;t like.  (There must be another error we can raise &#8212; I don&#8217;t entirely like the <code>render '/404.html', status: 404</code> solution for several reasons.)</p>
<img src="http://feeds.feedburner.com/~r/BenjaminOakes/~4/GvvQprNiX1M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.benjaminoakes.com/2011/09/15/activerecordconnectionnotestablished-in-rails-3-1-on-heroku/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.benjaminoakes.com/2011/09/15/activerecordconnectionnotestablished-in-rails-3-1-on-heroku/</feedburner:origLink></item>
		<item>
		<title>relative_time_ago in Padrino should be time_ago_in_words</title>
		<link>http://feedproxy.google.com/~r/BenjaminOakes/~3/X7fpgzBzBAE/</link>
		<comments>http://www.benjaminoakes.com/2011/09/14/relative_time_ago-in-padrino-should-be-time_ago_in_words/#comments</comments>
		<pubDate>Wed, 14 Sep 2011 13:01:19 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[helpers]]></category>
		<category><![CDATA[Padrino]]></category>
		<category><![CDATA[time]]></category>

		<guid isPermaLink="false">http://www.benjaminoakes.com/?p=131</guid>
		<description><![CDATA[You might find relative_time_ago referenced in the Padrino Guides or Padrino Helpers RDocs, but that doesn&#8217;t exist. According to the Application Helpers guides, you probably want distance_of_time_in_words or time_ago_in_words. Example: %p = time_ago_in_words(my_date) ago For reasons I don&#8217;t quite understand, this documentation is also incorrect: time_ago_in_words(2.days.ago) => "2 days ago" The actual behavior is: time_ago_in_words(2.days.ago) [...]]]></description>
			<content:encoded><![CDATA[<p>You might find <code>relative_time_ago</code> referenced in the <a href="http://www.padrinorb.com/guides/home">Padrino Guides</a> or <a href="http://www.padrinorb.com/api/padrino-helpers/README_rdoc.html">Padrino Helpers RDocs</a>, but that doesn&#8217;t exist.</p>
<p>According to the <a href="http://www.padrinorb.com/guides/application-helpers">Application Helpers guides</a>, you probably want <code>distance_of_time_in_words</code> or <code>time_ago_in_words</code>.</p>
<p>Example:</p>
<pre><code>%p
  = time_ago_in_words(my_date)
  ago
</code></pre>
<p>For reasons I don&#8217;t quite understand, this documentation is also <b>incorrect</b>:</p>
<pre><code>time_ago_in_words(2.days.ago) => "2 days ago"</code></pre>
<p>The actual behavior is:</p>
<pre><code>time_ago_in_words(2.days.ago) => "2 days"</code></pre>
<p>I&#8217;m planning to move some of this into the <a href="https://github.com/padrino/padrino-framework">padrino-framework</a> project directly.  Incorrect documentation is worse than no documentation; maybe it will be more accurate if kept in the code.  :)</p>
<img src="http://feeds.feedburner.com/~r/BenjaminOakes/~4/X7fpgzBzBAE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.benjaminoakes.com/2011/09/14/relative_time_ago-in-padrino-should-be-time_ago_in_words/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.benjaminoakes.com/2011/09/14/relative_time_ago-in-padrino-should-be-time_ago_in_words/</feedburner:origLink></item>
		<item>
		<title>Accessing Cookies in Padrino/Sinatra</title>
		<link>http://feedproxy.google.com/~r/BenjaminOakes/~3/_X1MikAjCHI/</link>
		<comments>http://www.benjaminoakes.com/2011/09/12/accessing-cookies-in-padrinosinatra/#comments</comments>
		<pubDate>Mon, 12 Sep 2011 15:50:12 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[cookies]]></category>
		<category><![CDATA[Padrino]]></category>

		<guid isPermaLink="false">http://www.benjaminoakes.com/?p=129</guid>
		<description><![CDATA[Unlike in Rails, there is no global cookies object in Padrino or Sinatra. Instead, you need to use request.cookies within your request handler: get :index do my_value = request.cookies['my_value'] end]]></description>
			<content:encoded><![CDATA[<p>Unlike in Rails, there is no global <code>cookies</code> object in Padrino or Sinatra.  Instead, you need to use <code>request.cookies</code> within your request handler:</p>
<pre><code>get :index do
  my_value = request.cookies['my_value']
end
</code></pre>
<img src="http://feeds.feedburner.com/~r/BenjaminOakes/~4/_X1MikAjCHI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.benjaminoakes.com/2011/09/12/accessing-cookies-in-padrinosinatra/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.benjaminoakes.com/2011/09/12/accessing-cookies-in-padrinosinatra/</feedburner:origLink></item>
		<item>
		<title>Enforcing SSL in Padrino</title>
		<link>http://feedproxy.google.com/~r/BenjaminOakes/~3/ViiV2HgIMG4/</link>
		<comments>http://www.benjaminoakes.com/2011/09/07/enforcing-ssl-in-padrino/#comments</comments>
		<pubDate>Wed, 07 Sep 2011 15:42:30 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.benjaminoakes.com/?p=128</guid>
		<description><![CDATA[We&#8217;re trying rack-ssl-enforcer out on our Padrino-based project. It seems to work when configuring like so: # File: app/app.rb class MyApp < Padrino::Application # [...] configure :production do require 'rack-ssl-enforcer' use Rack::SslEnforcer end end We're using it with Padrino with some success. It's great that such a common need is really simple to set up. [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;re trying <code>rack-ssl-enforcer</code> out on our Padrino-based project. It seems to work when configuring like so:</p>
<pre><code>
# File: app/app.rb
class MyApp < Padrino::Application
  # [...]
  configure :production do
    require 'rack-ssl-enforcer'
    use Rack::SslEnforcer
  end
end
</code></pre>
<p>We're using it with Padrino with some success. It's great that such a common need is really simple to set up. However, even after looking through the docs further, I'm surprised that I can request over HTTP and I don't get redirected to HTTPS. I've yet to figure out the issue, but it seems to meet our needs just fine otherwise.</p>
<p>This is in response to Dan Mayer's article <a href="http://www.mayerdan.com/2010/08/force_all_sinatra_traffic_to_h.php">Force all Sinatra traffic to https</a>. I had started to comment, but his blog errored-out when submitting.  Thanks for posting it, Dan!</p>
<img src="http://feeds.feedburner.com/~r/BenjaminOakes/~4/ViiV2HgIMG4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.benjaminoakes.com/2011/09/07/enforcing-ssl-in-padrino/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.benjaminoakes.com/2011/09/07/enforcing-ssl-in-padrino/</feedburner:origLink></item>
		<item>
		<title>New open source projects: Maid and TabCarousel</title>
		<link>http://feedproxy.google.com/~r/BenjaminOakes/~3/TG-5Sev3JV0/</link>
		<comments>http://www.benjaminoakes.com/2011/06/21/new-open-source-projects-maid-and-tabcarousel/#comments</comments>
		<pubDate>Tue, 21 Jun 2011 18:38:01 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[GitHub]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.benjaminoakes.com/?p=126</guid>
		<description><![CDATA[I&#8217;ve been hard at work taking some code I had originally written for myself and packaging it up as two open source projects. I&#8217;ve been very happy about the amount of interest I&#8217;ve received in both. I encourage you to take a look and see if what I&#8217;ve released would be useful to you. Feedback [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been hard at work taking some code I had originally written for myself and packaging it up as two open source projects.  I&#8217;ve been very happy about the amount of interest I&#8217;ve received in both.  I encourage you to take a look and see if what I&#8217;ve released would be useful to you.  Feedback (and contributions) are welcome!</p>
<h2><a href="http://rubygems.org/gems/maid">Maid</a></h2>
<p>(<a href="http://rubygems.org/gems/maid">Install</a>, <a href="http://github.com/benjaminoakes/maid">Source Code</a>)</p>
<p>Be lazy! Let Maid clean up after you, based on rules you define.</p>
<p>Maid keeps files from sitting around too long, untouched. Many of the downloads and other files you collect can easily be categorized and handled appropriately by rules you define. Let the maid in your computer take care of the easy stuff, so you can spend more of your time on what matters.</p>
<p>Think of it like the email filters you might already have, but for files. Worried about things happening that you don’t expect? Maid doesn’t overwrite files and actions are logged so you can tell what happened.</p>
<p>Maid is inspired by the Mac OS X shareware program <a href="http://www.noodlesoft.com/hazel.php">Hazel</a>. This tool was created on Mac OS X 10.6, but should be generally portable to other systems. (Some of the more advanced features such as downloaded_from require OS X, however.)</p>
<p>Your rules are defined in Ruby, so easy rules are easy and difficult rules are possible.</p>
<h2><a href="http://chrome.google.com/webstore/detail/ddldimidiliclngjipajmjjiakhbcohn">TabCarousel</a></h2>
<p>(<a href="http://chrome.google.com/webstore/detail/ddldimidiliclngjipajmjjiakhbcohn">Install</a>, <a href="http://github.com/benjaminoakes/TabCarousel">Source Code</a>)</p>
<p>A Chrome extension to help you keep tabs on info you want to monitor. It&#8217;s great for cycling through tabs on an external display, like a TV.</p>
<p>TabCarousel is simple: open tabs you want to monitor throughout the day, then click the toolbar icon. To stop, click the icon again.</p>
<p>By default, TabCarousel will flip through your tabs every 15 s, reloading them every 5 min. It&#8217;s great on a unused display or TV. Put Chrome in full-screen mode (F11, or cmd-shift-f on the Mac) and let it go.</p>
<p>If you want to change how often TabCarousel flips through your tabs, right click on the toolbar icon and choose &#8220;Options&#8221;.</p>
<p><b>Example Uses</b></p>
<p>On a HDTV that has a computer attached, open the NewRelic overview (and Background Tasks, etc.) for each app you&#8217;d like to monitor. Set NewRelic to kiosk mode for each page, then hit the &#8220;Tab Carousel&#8221; toolbar button.</p>
<p>The <a href="https://github.com/benjaminoakes/TabCarousel/wiki">TabCarousel wiki</a> has more.</p>
<img src="http://feeds.feedburner.com/~r/BenjaminOakes/~4/TG-5Sev3JV0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.benjaminoakes.com/2011/06/21/new-open-source-projects-maid-and-tabcarousel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.benjaminoakes.com/2011/06/21/new-open-source-projects-maid-and-tabcarousel/</feedburner:origLink></item>
		<item>
		<title>throw/catch vs. raise/rescue</title>
		<link>http://feedproxy.google.com/~r/BenjaminOakes/~3/00H-I1Wh3bM/</link>
		<comments>http://www.benjaminoakes.com/2011/03/22/throwcatch-vs-raiserescue/#comments</comments>
		<pubDate>Tue, 22 Mar 2011 02:13:41 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[catch]]></category>
		<category><![CDATA[raise]]></category>
		<category><![CDATA[rescue]]></category>
		<category><![CDATA[throw]]></category>

		<guid isPermaLink="false">http://www.benjaminoakes.com/?p=123</guid>
		<description><![CDATA[Just a piece of Ruby trivia: Ruby has both throw/catch as well as raise/rescue. Most newbie Rubyists don&#8217;t know this. There&#8217;s a section of the Pickaxe book that discusses them both. Essentially, rescue is used for exceptions and error control while catch is used for symbols and flow control. The idea is that you shouldn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>Just a piece of Ruby trivia:  Ruby has <em>both</em> <code>throw</code>/<code>catch</code> as well as <code>raise</code>/<code>rescue</code>.  Most newbie Rubyists don&#8217;t know this.  There&#8217;s a <a href="http://ruby.activeventure.com/programmingruby/book/tut_exceptions.html">section of the Pickaxe book</a> that discusses them both.</p>
<p>Essentially, <code>rescue</code> is used for exceptions and error control while <code>catch</code> is used for symbols and flow control.  The idea is that you shouldn&#8217;t use exceptions to change the flow of your program, but rather to handle errors.</p>
<img src="http://feeds.feedburner.com/~r/BenjaminOakes/~4/00H-I1Wh3bM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.benjaminoakes.com/2011/03/22/throwcatch-vs-raiserescue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.benjaminoakes.com/2011/03/22/throwcatch-vs-raiserescue/</feedburner:origLink></item>
	</channel>
</rss>

