Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Add parent query methods #97
While adding ancestry to some STI classes I found myself wanting to add a validation to restrict non-leaf nodes:
class Leaf < ActiveRecord::Base has_ancestry validate :parent_is_leaf_group, if: :parent? def parent_is_leaf_group errors.add :parent, "is not leaf group" unless parent.is_a? LeafGroup end end class LeafGroup < Leaf # Things Leaf can't have... end
Sadly, my friend the query attribute method (
Tests were added also, but one test on master was already failing.