94: def nested_set_options_for_select(class_or_item, options=nil)
95:
96: if class_or_item.is_a? Class
97: first_item = class_or_item.root
98: else
99: first_item = class_or_item
100: end
101: raise 'Not a nested set model !' if !first_item.respond_to? :acts_as_nested_set_options
102:
103:
104: if options.is_a? Hash
105: text_column = options[:text_column]
106: options.delete_if { |key, value| key != :exclude }
107: else
108: options = nil
109: end
110: text_column ||= first_item.acts_as_nested_set_options[:text_column]
111:
112: tree = first_item.full_set(options)
113: if block_given?
114: tree.map{|item| [yield(item), item.id] }
115: else
116: tree.map{|item| [ "#{'ยทยท' * item.level}#{item[text_column]}", item.id]}
117: end
118: end