Skip to content

Instantly share code, notes, and snippets.

@marclipovsky
Created September 1, 2011 09:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marclipovsky/1185839 to your computer and use it in GitHub Desktop.
Save marclipovsky/1185839 to your computer and use it in GitHub Desktop.
class Category < ActiveRecord::Base
has_many :tickets
has_many :tasks, :dependent => :destroy
accepts_nested_attributes_for :tasks, :reject_if => lambda { |a| a[:name].blank? }, :allow_destroy => true
acts_as_tree
has_friendly_id :name, :use_slug => true
scope :parent, where({:parent_id => nil}, {})
scope :children, where({'parent_id > ?', 0}, {})
end
class Tasks < ActiveRecord::Base
belongs_to :category
belongs_to :ticket
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment