action-store icon indicating copy to clipboard operation
action-store copied to clipboard

There are compatibility issues with Rails 7.2

Open szluyufeng opened this issue 1 year ago • 4 comments

Upgrading to Rails 7.2 gives you an error, which may be a problem with the 'constantize' method.

szluyufeng avatar Aug 25 '24 10:08 szluyufeng

Please give more error log, I have test in PR #20, it looks like Rails 7.2 can work.

huacnlee avatar Sep 24 '24 01:09 huacnlee

OK. Thanks for your effort on this.

After upgrading to 7.2, running bin/dev throws this error:

00:58:45 web.1    | => Booting Puma
00:58:45 web.1    | => Rails 7.2.0 application starting in development 
00:58:45 web.1    | => Run `bin/rails server --help` for more startup options
00:58:45 web.1    | Exiting
00:58:45 web.1    | /Users/macbookm2/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.2.0/lib/active_support/inflector/methods.rb:290:in `const_get': uninitialized constant Star (NameError)
00:58:45 web.1    | 
00:58:45 web.1    |       Object.const_get(camel_cased_word)
00:58:45 web.1    |             ^^^^^^^^^^
00:58:45 web.1    |     from /Users/macbookm2/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.2.0/lib/active_support/inflector/methods.rb:290:in `constantize'
00:58:45 web.1    |     from /Users/macbookm2/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.2.0/lib/active_support/core_ext/string/inflections.rb:74:in `constantize'
00:58:45 web.1    |     from /Users/macbookm2/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/action-store-1.1.3/lib/action_store/mixin.rb:41:in `action_store'
00:58:45 web.1    |     from /Users/macbookm2/dev/webtest/app/models/user.rb:69:in `<class:User>'

The code at user.rb:69 is as follows:

class User < ApplicationRecord
  action_store :star, :post, counter_cache: true, action_class_name: 'Star'
end

szluyufeng avatar Sep 27 '24 17:09 szluyufeng

Do you have models/star.rb, please show me you models folder

huacnlee avatar Sep 28 '24 02:09 huacnlee

Yes it has.

class Star < Action
  self.table_name = "stars"
end

szluyufeng avatar Sep 28 '24 06:09 szluyufeng