Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order column (option) as a symbol #46

Closed
leonelgalan opened this issue Mar 12, 2013 · 2 comments
Closed

Order column (option) as a symbol #46

leonelgalan opened this issue Mar 12, 2013 · 2 comments

Comments

@leonelgalan
Copy link

When setting the order column a string must be used, using a symbol won't work.

Works

acts_as_tree order: 'position'

It doesn't

acts_as_tree order: :position

I don't have a good explanation for why would this be better, other than it feels more natural and it wouldn't take much, changing:

https://github.com/mceachen/closure_tree/blob/master/lib/closure_tree/columns.rb#L71

# c = ct_class.columns_hash[order_option]
c = ct_class.columns_hash[order_option.to_s]

Should work with both strings and symbols.

UPDATE
I'm fairly new to testing, but a failing test could look something like this:

# spec/support/models.rb
class OtherLabel < Label
  acts_as_tree :order => :sort_order
end

# spec/label_spec.rb
  context "OtherLabel" do
    it "should include DeterministicNumericOrdering" do
      OtherLabel.include?(ClosureTree::DeterministicNumericOrdering).should be_true
    end
  end
@mceachen
Copy link
Collaborator

OK. I'll do this after I get #49 squared away.

@mceachen
Copy link
Collaborator

This is released in 4.0.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants