Skip to content

Instantly share code, notes, and snippets.

@mathie
Created April 22, 2016 05:26
Show Gist options
  • Save mathie/4f25c3e4bdc1036248f9a9354a9dc8fe to your computer and use it in GitHub Desktop.
Save mathie/4f25c3e4bdc1036248f9a9354a9dc8fe to your computer and use it in GitHub Desktop.
class Node < ActiveRecord::Base
def root
if root_id = path.first
self.class.find(root_id)
else
self
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment