// A skewed take on the consulting business.
 

Careful with that config.gem, Eugene
Posted by Kevin on April 10, 2009 18:02

With the advent of Github as the Ruby Gem hosting platform of choice, you have to be specific when you use config.gem in you config/environment.rb file.

Recently, I noticed that my Rails application generated from a You've Got Rails template was choking on the rubyist-aasm library. Given the following configuration in config/environment.rb:

  config.gem "rubyist-aasm"

Which would yield the following errors initially discovered when running Rake:

  no such file to load -- rubyist-aasm
  ...
  Missing these required gems:
    rubyist-aasm

The problem appears due to Github namespacing gems by prefixing the username to the Gem name. The solution is to specify the actual library name:

  config.gem "rubyist-aasm", :lib => "aasm", :source => "http://gems.github.com"
Caching Rails Pages with Passenger and a Sub-URI
Posted by Kevin on January 21, 2009 03:06

Ever since I started using blurt for my blog, I have wanted to add page caching. Patrick, the author, thinks it is premature optimization -- especially since no one reads our blogs anyway (or at least mine). My view is that performance really stinks on a 256 MB shared slice. By implementing page caching, pages that used to take between a few hundred ms and a few seconds, are now instantaneous. About as digg safe as a single, puny, server can be!

Getting it working wasn't that easy, though. I followed the usual suspects for page caching, but kept running into weird issues with the sweepers. We were originally frozen at Rails 2.1.1, and I think most of the obvious problems were fixed by upgrading to 2.2.2. Once things appeared working, I deployed to production only to be greeted with new issues. Seems I forgot to configure my developer Passenger instance to use a sub URI like I'm doing in production.

The first bit of Google-delivered help was Paul Gross's article on using Mephisto with Phusion Passenger with a custom cache directory. Of course, that's for a website without a sub-URI. Before I could address that issue, I needed to fix a Rails 2.2.2 problem. It pays to read the release notes, and luckily for me someone else had.

First, add the following to your appropriate environment. If you are doing things right, it should be in config/environment.rb and not config/environments/production.rb:

  config.action_controller.relative_url_root = "<sub-uri>"

Next, remove "config.action_view.cache_template_loading = true" from config/environments/production.rb.

Now you are ready to engage in mod_rewrite hacking! A useful trick is to actually log what mod_rewrite is doing. Add the following lines to your apache config (virtual host or other):

        RewriteLog /var/log/apache2/<domain>-rewrite.log
        RewriteLogLevel 3

After playing around for a bit, Paul's rewrite code turned into:

        RailsAllowModRewrite on
        RewriteEngine on
        RewriteRule ^/<sub-uri>/?$ /<sub-uri>/cache/index.html [QSA]
        RewriteRule ^/<sub-uri>/([^.]+?)/?$ /<sub-uri>/cache/$1.html [QSA]
        RewriteCond %{DOCUMENT_ROOT}/<sub-uri>/cache/%{REQUEST_FILENAME} -f
        RewriteRule ^/<sub-uri>/(.*)$ /<sub-uri>/cache/$1 [L]

Hopefully this helps prevent someone from futzing around in circles for a few hours.

A Little Announcement...
Posted by Kevin on January 13, 2009 06:10

There have been a lot of aborted blog posts during the last month as I'm trying to leave the fluff to the other bloggers!

While I should have a substantial post this week containing real code, I do have an announcement. With the help of Brooke Kuhlmann, I have launched Not Just Ruby, a Colorado Springs Meetup group that starts with Ruby, and then includes pretty much all overlapping topics that might be relevant. The goal is to provide Rubyists, and Ruby-curious, a place to share information about Ruby and the other compatible technologies. Think Photoshop, agile methods, accounting, marketing, SEO, and business planning. All of these topics are interconnected, interesting in their own right, but either there aren't groups specific to them, or no one really wants to sit through 2 hours every month. By providing a broad canvas, people may indulge their different interests and learn about things that might be on their neglected to do list.

While Colorado Springs is an awesome place to live, the larger businesses are pretty much in either the Java or .Net camps. Ruby, and it's offspring Ruby on Rails, provides huge productivity gains and cost savings for small to medium projects. Larger projects are trickier, but no more so than Java or .Net. Building a strong and vibrant community is the best way to get the attention of businesses, and by including the parallel technologies, we can virally infiltrate the strongholds of Java and .Net.

 
 
© 2012 Concepts Ahead :: Logo Design by Peyton Crump :: Powered by Blurt