Skip to content

Instantly share code, notes, and snippets.

@ExByt3s
Created February 9, 2015 22:45
Show Gist options
  • Save ExByt3s/116e1f10e1bfb5e4d2aa to your computer and use it in GitHub Desktop.
Save ExByt3s/116e1f10e1bfb5e4d2aa to your computer and use it in GitHub Desktop.
class Category < ActiveRecord::Base
belongs_to :root, class_name: "Category", :foreign_key => "category_id"
has_many :subcategories, class_name: "Category", foreign_key: "category_id"
has_many :auditions
private
def self.roots
find(0)
end
def self.subs(params)
subs = where(category_id: params)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment