0

I got the following error after executing bundle exec rake db:migrate

/usr/lib/ruby/gems/1.8/gems/ancestry-2.1.0/lib/ancestry/instance_methods.rb:77: syntax error, unexpected ':', expecting ')'
          self.class.where(id: (ancestor_ids + ancestor_ids_...
                              ^
/usr/lib/ruby/gems/1.8/gems/ancestry-2.1.0/lib/ancestry/instance_methods.rb:77: syntax error, unexpected ')', expecting kEND
..._ids + ancestor_ids_was).uniq).each do |ancestor|

actual code in instance_methods is

Touch each of this record's ancestors

def touch_ancestors_callback

  # Skip this if callbacks are disabled
  unless ancestry_callbacks_disabled?

    # Only touch if the option is enabled
    if self.ancestry_base_class.touch_ancestors

      # Touch each of the old *and* new ancestors
      self.class.where(id: (ancestor_ids + ancestor_ids_was).uniq).each do |ancestor|
        ancestor.without_ancestry_callbacks do
          ancestor.touch
        end
      end
    end
  end
end

I compared the code with https://github.com/stefankroes/ancestry/blob/master/lib/ancestry/instance_methods.rb#L97 I am not understanding why i am getting that error. Please help me out.

Thank you in advance.

1
  • 1
    you're using gem with incompatible ruby version. use ruby 2.0 at least. Commented Nov 1, 2014 at 22:11

1 Answer 1

1

This gem uses the new syntax for hashes that was introduced with Ruby 1.9. But you run this code with Ruby 1.8 what does not understand this syntax.

You have two options:

  • Find and use an older version of the Gem that uses the "old" syntax. If sucha a version even exists depends on how old the gem is. Or

  • Upgrade to a newer Ruby version.

I would advise upgrading Ruby, because 1.8 is outdated for years now and does not get security updates anymore (Read: https://www.ruby-lang.org/en/news/2013/12/17/maintenance-of-1-8-7-and-1-9-2/)

Sign up to request clarification or add additional context in comments.

1 Comment

i found ancestry 1.2.5 which is compatible with ruby 1.8. now it successfully executed. thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.