Class Category
In: app/models/category.rb
Parent: ActiveRecord::Base

Methods

Public Class methods

[Source]

    # File app/models/category.rb, line 35
35:   def self.columns_for_index
36:     [ {:label => "Name", :method => :name, :order => "categories.name" },
37:       {:label => "Type", :method => :category_type_name, :order => "category_types.name" },
38:       {:label => "Updated On", :method => :updated_on_string, :order => "categories.updated_at"}  ]
39:   end

Public Instance methods

[Source]

    # File app/models/category.rb, line 16
16:   def ancestors
17:     fn = lambda do |cat, parents|
18:       if cat.parent_id
19:         p = self.class.find(cat.parent)
20:         fn.call(p, (parents << p))
21:       else
22:         parents.reverse
23:       end
24:     end
25:     fn.call(self, [])
26:   end

[Source]

    # File app/models/category.rb, line 32
32:   def category_type_name
33:     category_type ? category_type.name : nil
34:   end

[Source]

    # File app/models/category.rb, line 28
28:   def path(sep=" > ")
29:     (ancestors.map(&:name) + [name]).join(sep)
30:   end

[Validate]