Mike Owens


Renaissance Hacker Extraordinaire (look at the ego on this one)

Filespanker LLC

August 9
August 7

Rails State Machine

I think it’s crazy when I implement something that “Surely, I’m the only one that’ll ever use this”, and then another implementation ends up in Rails proper. Last year, I wrote acts_as_fsm; a state machine implementation for ActiveRecord models:

SaleMachine = Fsm::state_machine do
  state :new    => :queued
  state :queued => :new

  state :queued => :on_site do |sale, old, new|
    sale.started_at = Time.now
  end

  state :on_site => :processing_orders do |sale, old, new|

    sale.ended_at = Time.now
    sale.orders.each do |o|
      o.status_items <<
        OrderStatusItem.new(:status  => "CLOSE_WAIT",
                            :message => "Sale ended.  Waiting for a few stragglers" );
      o.save!
    end
  end

  state :processing_orders => :shipped
end
And then, to use the machine:
class Sale < ActiveRecord::Base
  acts_as_fsm :machine => SaleMachine
end
There is nothing I love more than throwing away code I wrote and migrating to something in the framework. Less stuff for me to maintain. Check out ActiveRecord::StateMachine.

July 29

Code on Paper

Trying to reason about code with pen-and-paper is a distressing experience. Like trying to explain guitar scales without a guitar nearby.

July 23

Git+Trac = Awesome

I’ll be blunt and say Trac is only open source issue tracker both designed for humans, and with enough features to make it realistically usable, and it seems to be pretty popular. I’ve used it for years.

Obviously, git seems to be the defacto DVCS these days.

Why on earth do must I install a self-described “proof of concept” plugin to make the two work together?

As an aside, the plugin does seem to work wonderfully.

July 12
+
July 11
+
+
July 8