Category: Rails

  • Integrate GTD with Gmail using Firefox

    Getting Things Done is a book by David Allen. The methodology from the book, commonly referred to as GTD, has become quite popular inside certain tech circles. I’ve been using GTD for roughly a year now. I can’t claim to be an expert at it, but it’s helped me stay organized during a period of my life that would otherwise have been extremely unorganized.

    There are many tools out there that make implementing GTD on your computer fairly painless. For you fellow Mac cultists, Actiontastic does the job nicely with a clean, minimalist interface. There is also Tracks, a Rails-based web application that you can install… well, pretty much wherever. What I’d like to introduce in this post, though, is a unique Firefox extension called GTDGmail.

    GTDGmailI’ve been using GTDGmail for a few months now. Once installed, it integrates with Gmail and modifies your view slightly. Among other things, it divides your tags into four categories: projects, contexts, statuses, and references. As e-mail messages come in, you can categorize them as actions by tagging them with the “Action” status. If an e-mail contains important information you’d like to keep for future reference, tag it with a “Reference” and a “Project.” As you tag your e-mail, it becomes available under GTDGmail’s pre-built search links that appear above your tags.

    You can also send yourself actions and references. This is where the famous GTD practice of “capturing” comes into play. The idea is to get all that stuff floating around in your head out and organized into action items. Sending yourself an action or a reference results in a new e-mail message in your inbox, automatically tagges as an action or a reference and ready to be organized further into projects and contexts.

    GTDGmail also has some handy non-GTD uses. For example, it makes regular tagging much easier by placing links at the top of each e-mail, one link for each tag. Simply click on a link to add that tag to the e-mail you’re currently viewing. Click the red X next to the tag to remove it from the e-mail. This is much faster than scrolling through a drop-down to find the tag you want to add or remove.

    The only downside to GTDGmail is that it does make Gmail less responsive. Since GTDGmail has to overlay Gmail’s existing layout with additional information, it can get bogged down at times. However, the upside of being able to immediately categorize your incoming e-mail into action items more than makes up for this. GTDGmail is not for everyone, but I encourage you to try it out to see if it fits your own organizational style.

  • Show database migration versions with Rake

    Something I frequently need to do when deploying a Rails application is determine the current migration version of a database. In the past, I’ve done this by bringing up mySQL and typing:

    SELECT version FROM schema_info

    Well, I’m finally tired of doing that so I cooked up this Rake task:

    namespace :db do
      desc "Print current database migration version to the console"
      task :version => :environment do
        puts "VERSION=#{ActiveRecord::Migrator.current_version}"
      end
    end
    

    To install, copy and paste into lib/tasks/common.rake (or wherever you store your custom Rake tasks). Then fire up a terminal window and feel the power:

    $ rake db:version
    (in /Users/matt/project)
    VERSION=125
    

    I’m surprised this isn’t already in Rails. Sure, there’s script/about, but I always forget to use it. It also spits out other information I don’t typically need to know.

    Why care about the migration version in the first place? When you’re on a project with multiple Rails deployments (dev/test/prod) and multiple developers creating migrations in multiple branches, it comes in quite handy.

  • Teascript goes live

    TeascriptI’m proud to announce that Teascript went live early last week. It’s been a long several months since originally conceiving the idea, building the app, beta testing, and deploying but now it’s finally ready for prime time.

    Teascript is a Rails application that makes it easy to design and build professional high school transcripts. It’s mainly targeted towards home school parents and students, however, I’ve received interest from several public and private schools who are looking for a transcript generation package they can install locally so the potential for this product seems huge.

    For those interested in how Teascript was deployed, the application runs on Apache 2.2 with mod_proxy_balancer and a cluster of Mongrels. I’m using a VPS provided by Slicehost. This setup has been rock solid so far.

    My talk at RailsConf this year will focus on the development of Teascript: how the target niche was chosen, how the application was marketed, and so on. My goal is to demonstrate how the principles outlined in 37 Signals’ book Getting Real and the homesteading concepts put forth by Nathaniel Talbott at last year’s RailsConf were combined to produce a web product that is self-maintaining, sustainable, and capable of generating passive income.

    So please, check out Teascript and let me know what you think.

  • RailsConf registration is open

    RailsConf registration is open. Time to scramble! From what I understand one-third of the seats are already taken. I’ll be speaking at the conference this year. Should be more fun than a barrel of monkeys. See you there.

  • Converting Mike’s Capistrano Cadillac into a Camero

    Mike Clark made a recent post on his blog about how to handle Rails versions with Capistrano. Very nice stuff. I’ve put his code samples to immediate use with an app I’m preparing to convert to Rails 1.2.1.

    I’ve run into some trouble this week, though, as I want to update one of my client projects that still runs version 1.1.6 of Rails. Mike’s Capistrano task takes a revision number so checking out a fresh copy with his script looks something like this.

    rake deploy_edge REVISION=5990 RAILS_PATH=/path/to/shared/rails
    

    This checks out 1.2.1 into the specified directory. After spending a few minutes trying to find the revision number for 1.1.6 (and chatting briefly with my Campfire peeps about the best way to proceed) I’ve decided that it’s safer to use tags instead of revisions. Deploys now look like this:

    rake deploy_edge TAG=rel_1-1-6 RAILS_PATH=/path/to/shared/rails
    

    Much more readable. The only downside, of course, is losing revision granularity. I’m essentially tied to the whim of the Core team as to when they decide to create new tags. But on the other hand, most of my projects aren’t currently running on Edge so this is suitable for my needs at the moment.

    I’ve included my rewrite of the task below. Just drop it in common.rake or wherever you prefer to put your custom tasks. Reading Mike’s post would be a good idea too since he explains how to get this working with a remotely deployed Rails application.

    (more…)

  • Montastically cool

    I have a web site I’ve been working on that tends to go down at odd times during the night. It’s an issue with the web host, and due to financial constraints my client is not willing to relocate the site anytime soon. So I’m stuck with having to log in and reset everything whenever the site goes down. It only happens once a month or so, but since the site receives a small amount of traffic it often takes several hours (sometimes several days) for anyone to inform me that it’s down. Enter Montastic.

    It’s rare that a free service comes along that is dead simple to use, works the first time (and every single time after that), and is ad-free. Montastic scores 110% on all counts. It’s a web-based monitoring service written in Rails that delivers notification via e-mail or RSS when a monitored site goes down.

    Montastic’s UI is very straightforward, some might say even elegant. Sign-up took a few seconds. Logging in, a few more. Adding my site was a breeze (it only asks for the URL, amazingly enough). I subscribed to my feed and was off and running.

    Montastic has already proven useful by alerting me to a server that went down just a few hours prior to writing this review. My sleep is that much easier knowing that Montastic is out there, ready to sound the alarm if my sites so much as twitch.

    Go ahead, try it out.

  • Dave’s EuroRailsConf keynote

    Dave Thomas’ keynote from last year’s EuroRailsConf is now online. It’s about 45 minutes long and well worth watching. Dave discusses terrorism, risk, and how it relates to Rails. This really scratched an itch for me because I’m in a work situation right now where I’m dealing with a great deal of risk. The funny thing about risk is that it’s something that can’t be fully avoided, yet many people delude themselves into thinking that it can.

  • Rails test results without the cruft

    Ever notice the cruft you get when running Rails tests from the command line? It’s horrible, especially if your project has more than a dozen test files:

    /opt/local/bin/ruby -Ilib:test "/opt/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake/rake_test_loader.rb"
    "test/unit/activity_test.rb" "test/unit/address_test.rb" "test/unit/application_helper_test.rb"
    "test/unit/course_calculations_test.rb" "test/unit/course_test.rb" "test/unit/course_type_test.rb"
    "test/unit/credit_hour_test.rb" "test/unit/email_test.rb" "test/unit/exam_test.rb" "test/unit/gender_test.rb"
    "test/unit/grade_test.rb" "test/unit/level_test.rb" "test/unit/notifier_test.rb" "test/unit/numeric_test.rb"
    "test/unit/obfuscator_test.rb" "test/unit/order_test.rb" "test/unit/school_test.rb" "test/unit/string_test.rb"
    "test/unit/student_test.rb" "test/unit/transcript_test.rb" "test/unit/user_test.rb" 
    Loaded suite /opt/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake/rake_test_loader
    Started
    ..................................................................
    Finished in 2.509903 seconds.
    
    66 tests, 140 assertions, 0 failures, 0 errors
    

    M@ McCray recently posted a hack to the Terralien Campfire that gives you a nice, clean summary instead:

    Loaded suite /opt/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake/rake_test_loader
    Started
    ..................................................................
    Finished in 2.855885 seconds.
    
    66 tests, 140 assertions, 0 failures, 0 errors
    

    Want to start enjoying this super slim summary yourself? Just stick this code in your project’s Rakefile right before the require 'tasks/rails' bit:

    Rake::TestTask.class_eval do
      alias_method :crufty_define, :define
      def define
        @verbose = false
        crufty_define
      end
    end
    

    Much better! We’re both surprised something like this isn’t already available in Core.

  • Port of the Ocadia theme to Mephisto

    Ocadia PreviewI began poking around the intriguing Rails-based Mephisto blogging engine this weekend. While the app itself looks quite promising, there is a noticeable absence of themes for it. I’m sure this will change, but in the meantime I thought I’d make my own contribution. The particular blog I’m converting originally ran on Becca Wei’s excellent Ocadia theme for WordPress so I went ahead and ported it to Mephisto. If you’re interested in using it on your own blog, download a copy and check out the README for installation instructions. Enjoy!

    Update: Ocadia now has a home on GitHub. This means you now have the ability to check out the source code like this:

    git clone git://github.com/pelargir/ocadia_mephisto.git
    
  • Don’t leave empty test fixtures in your Rails projects

    A friendly word of advice: don’t leave empty test fixtures in your Rails projects. In some situations, it can cause unexpected test failures that are quite nasty to track down.