5

I upgraded our app to Rails 6.1.4.4 and Ruby 3.0.2. I have this old gem

gem 'acts_as_commentable'

Locked at version 4.0.2. The gem does not appear to be supported anymore, which is a shame because when I start up my app or console, I now get this error

$ rails c
Your Gemfile lists the gem rspec-rails (>= 0) more than once.
You should probably keep only one of them.
Remove any duplicate entries and specify the gem only once.
While it's not a problem now, it could cause errors if you change the version of one of them later.
/Users/myuser/.rvm/gems/ruby-3.0.2/gems/hash_dot-2.5.0/lib/hash.rb:19:in `method_missing': undefined method `arity' for {:as=>:commentable, :dependent=>:destroy}:Hash (NoMethodError)
    from /Users/myuser/.rvm/gems/ruby-3.0.2/gems/activerecord-6.1.4.4/lib/active_record/associations/builder/association.rb:53:in `build_scope'
    from /Users/myuser/.rvm/gems/ruby-3.0.2/gems/activerecord-6.1.4.4/lib/active_record/associations/builder/association.rb:47:in `create_reflection'
    from /Users/myuser/.rvm/gems/ruby-3.0.2/gems/activerecord-6.1.4.4/lib/active_record/associations/builder/association.rb:32:in `build'
    from /Users/myuser/.rvm/gems/ruby-3.0.2/gems/activerecord-6.1.4.4/lib/active_record/associations.rb:1458:in `has_many'
    from /Users/myuser/.rvm/gems/ruby-3.0.2/gems/acts_as_commentable-4.0.2/lib/commentable_methods.rb:58:in `acts_as_commentable'

    …

Is there any simple replacement for this gem or way to monkey-patch this error so I can start up the app?

Dave
  • 15,639
  • 133
  • 442
  • 830
  • 1
    I have not tried this: looked over some of the forks and found this one, `https://github.com/diegocharles/acts_as_commentable`. If `gem 'acts_as_commentable’, github: 'diegocharles/acts_as_commentable'` works, I'll add the answer. If it does not work, try: `https://github.com/PlymouthUniversitySD/acts_as_commentable` or find another one from `https://github.com/jackdempsey/acts_as_commentable/network/members` – razvans Jan 25 '22 at 07:53
  • I still see the error "NoMethodError: undefined method `arity' for {:as=>:commentable, :dependent=>:destroy}" adding "git: location" after gem 'acts_as_commentable', – Dave Jan 26 '22 at 19:47

1 Answers1

0

Looking over the forks, I found this one that appears to work for me using Rails 6.0.6 and Ruby 3.0.5.

https://github.com/alazycoder101/acts_as_commentable.git

I have not tested it extensively yet, but at least the basic functionality seems to be working for me. Hope this helps.

For clarity, to use that fork you would use the following line in your Gemfile:

gem 'acts_as_commentable', git: 'https://github.com/alazycoder101/acts_as_commentable.git'