Displaying 1 result from an estimated 1 matches for "set_default_company_from_parent".
2006 Aug 14
6
Testing fails with fixtures not when invoked directly
..._presence_of :name
end
** company.rb **
class Company < Organization
has_many :departments
end
** department.rb **
class Department < Organization
acts_as_tree
# acts_as_list :scope => :parent_id
validates_presence_of :company_id
belongs_to :company
before_validation :set_default_company_from_parent
protected
def set_default_company_from_parent
self.company_id ||= self.parent.company_id if self.parent
end
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060814/f859b339/attachment.html