Skip to content

Instantly share code, notes, and snippets.

@hakanensari
Created July 30, 2009 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hakanensari/158742 to your computer and use it in GitHub Desktop.
Save hakanensari/158742 to your computer and use it in GitHub Desktop.
Modeling bookkeeping app in Rails
class Account < ActiveRecord::Base
acts_as_tree
belongs_to :asset_type
has_many :transactions
end
class AssetType < ActiveRecord::Base
has_many :accounts
end
class Transaction < ActiveRecord::Base
belongs_to :account
has_many :transactionships
has_many :matches,
:through => :transactionships,
:after_add => :add_inverse,
:after_remove => :remove_inverse
end
class Transactionship < ActiveRecord::Base
belongs_to :transaction
belongs_to :match, :class_name => "Transaction", :foreign_key => "match_id"
end
class Person < ActiveRecord::Base
belongs_to :person_type
end
class PersonType < ActiveRecord::Base
has_many :people
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment