Created
April 28, 2009 00:35
-
-
Save dnch/102847 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # assuming the following columns in `things` | |
| # | |
| # children_counter_cache :integer | |
| # parent_id :integer | |
| # | |
| class Thing < ActiveRecord::Base | |
| has_many :children, :class_name => "Thing", :foreign_key => "parent_id", :dependent => :nullify | |
| belongs_to :parent, :class_name => "Thing", :foreign_key => "parent_id", :counter_cache => 'children_counter_cache' | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment