Skip to content

Instantly share code, notes, and snippets.

View obrie's full-sized avatar

Aaron Pfeifer obrie

View GitHub Profile
class CreditCardType < ActiveRecord::Base
acts_as_enumeration :lookup_name
column :name
def initialize(attributes = nil)
super
self.lookup_name ||= name.to_s.gsub(/[^A-Za-z0-9-]/, '').underscore
end
create :id => 1, :name => 'Visa'
@obrie
obrie / state_machine_model.rb
Created May 5, 2011 16:55 — forked from mghaught/state_machine_model.rb
state_machine setup
state_machine :checkout_state, :initial => :address, :use_transactions => false do
state :delivery
state :payment
state :confirm
state :complete
event :next do
transition :from => :address, :to => :delivery
transition :from => :delivery, :to => :payment
transition :from => :payment, :to => :confirm