skyeagle/nested_set — pull request #58 by shatsar (2013-04-11 03:31:11+00:00)
Title: Improving nested_set_option helper method to support query results (checking the 'each' support)

I have a structure Brand -> Categories, I would like to limit the options in the the ```select``` element to show the categories of the current brand, like this:

```ruby
nested_set_options(@brand.categories.roots, @category) {|i, level| ....
```

with this result:
> NoMethodError: undefined method `self_and_descendants' for #

the problem, simulating via rails console the flow in the ```nested_set_options`` helper was this:

```ruby
1.9.3-p362 :019 > b = Brand.find 1
1.9.3-p362 :020 > b.categories.roots.is_a? (Array)
=> false
```
but
```ruby
1.9.3-p362 :026 > b.categories.roots.respond_to?(:each)
=> true
```

So I changed the helper to check the input 'each' support, instead of being an array.

Let me know if I'm missing something, thanks for your work!