Rails

Like any Rails application, we write quite a few rake tasks to automate activities. Rake is great, but I’ve always been frustrated with the logging. We would use puts in the rake tasks, but other components that used Rails.logger wouldn’t show up in the console - they were going to [environment].log. So I created a simple rake task to switch the logging to STDOUT: #Sets up logging - should only be called from other rake tasks task setup_logger: :environment do logger = Logger.new(STDOUT) logger.level = Logger::INFO Rails.logger = logger end Because this picks up our typical dependency - environment - I can replace environment with setup_logger: desc <<-DESC Creates a job: outreach:jobs:create[<job>,<org>,<args>] Ex: outreach:jobs:create[distribute,community,job_name:close_cases,immediate:true] DESC task :create, [:job_name, :org_short_name] => :setuplogger do |, args| JobLauncher.launch args[:job_name], args[:org_short_name], parse_extras(args) end This seems like an obvious fix, but I haven’t seen it used before.

Pow!, created by the 37 Signals team, is a “zero-config Rack server for Mac OS X”. If you’re working on multiple applications that are connected, it’s a great tool to keep all of your sites up and running on your machine. Homebrew, “the missing package manager for OS X” makes installing applications simple. Most of the time it just works, and when extra steps are needed, Homebrew usually explains what you need to do once the install is complete.