lib/zendesk_api/association.rb
def generate_path(*args)
      options = SilentMash.new(:with_id => true)
      if args.last.is_a?(Hash)
        original_options = args.pop
        options.merge!(original_options)
      end

      instance = args.first

      namespace = @options[:class].to_s.split("::")
      namespace[-1] = @options[:class].resource_path

      # Remove components without path information
      ignorable_namespace_strings.each { |ns| namespace.delete(ns) }
      has_parent = namespace.size > 1 || (options[:with_parent] && @options.parent)

      if has_parent
        parent_class = @options.parent ? @options.parent.class : Association.class_from_namespace(ZendeskAPI::Helpers.modulize_string(namespace[0]))
        parent_namespace = build_parent_namespace(parent_class, instance, options, original_options)
        namespace[1..1] = parent_namespace if parent_namespace
        namespace[0] = parent_class.resource_path
      else
        namespace[0] = @options.path || @options[:class].resource_path
      end

      if id = extract_id(instance, options, original_options)
        namespace << id
      end

      namespace.join("/")
    end
def generate_path(*args)
      options = SilentMash.new(:with_id => true)
      if args.last.is_a?(Hash)
        original_options = args.pop
        options.merge!(original_options)
      end

      instance = args.first

      namespace = @options[:class].to_s.split("::")
      namespace[-1] = @options[:class].resource_path

      # Remove components without path information
      ignorable_namespace_strings.each { |ns| namespace.delete(ns) }
      has_parent = namespace.size > 1 || (options[:with_parent] && @options.parent)

      if has_parent
        parent_class = @options.parent ? @options.parent.class : Association.class_from_namespace(ZendeskAPI::Helpers.modulize_string(namespace[0]))
        parent_namespace = build_parent_namespace(parent_class, instance, options, original_options)
        namespace[1..1] = parent_namespace if parent_namespace
        namespace[0] = parent_class.resource_path
      else
        namespace[0] = @options.path || @options[:class].resource_path
      end

      if id = extract_id(instance, options, original_options)
        namespace << id
      end

      namespace.join("/")
    end
Options to pass in
 * class - Required
 * parent - Parent instance
 * path - Optional path instead of resource name
 Generate a path to the resource.
 id and <parent>_id attributes will be deleted from passed in options hash if they are used in the built path.
 Arguments that can be passed in:
 An instance, any resource instance
 Hash Options:
 * with_parent - Include the parent path (false by default)
 * with_id - Include the instance id, if possible (true)