Module: Inkwell::ActsAsInkwellCategory::ClassMethods

Includes:
Common, Constants
Defined in:
lib/acts_as_inkwell_category/base.rb

Instance Method Summary collapse

Methods included from Common

#category_class, #check_post, #check_user, #community_class, #community_id_attr, #get_class_for_item_type, #get_item_type, #get_owner_type, #post_class, #user_class, #user_id_attr

Instance Method Details

#get_categories_for(options = {}) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/acts_as_inkwell_category/base.rb', line 33

def get_categories_for(options = {})
  options.symbolize_keys!
  object = options[:object]
  type = options[:type]
  result = category_class.where :owner_id => object.id, :owner_type => type
  result.each do |category|
    parent_ids = ActiveSupport::JSON.decode category.parent_ids
    category.parent_category_id = parent_ids.last
  end
  result
end