Skip to content

Instantly share code, notes, and snippets.

@tjmcewan
Created June 26, 2011 07:37
Show Gist options
  • Save tjmcewan/1047368 to your computer and use it in GitHub Desktop.
Save tjmcewan/1047368 to your computer and use it in GitHub Desktop.
class Node < ActiveRecord::Base
validates :name, :presence => true
end
class Team < Node
delegate :name, :to => :profile
after_initialize do |team|
team.build_profile(:name => team[:name]) if team.new_record? && team.profile.nil?
end
end
class Team::Profile < ActiveRecord::Base
belongs_to :team
attr_accessible :name
validates :name, :presence => true, :on => :update
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment