Skip to content

Commit eaddeb1

Browse files
otegamikou
andauthored
Use ApplicationRecord for Redmine 6 or later (#130)
Related: #126 ## Issue CI failed because of the following error. ```console Error: FullTextSearch::SearchControllerTest::AttachmentTest#test_api: NoMethodError: undefined method `acts_as_event' for FullTextSearch::Target:Class ``` ref: https://github.com/clear-code/redmine_full_text_search/actions/runs/8164642884/job/22320305058 ## Cause `Redmine::Acts::Event` isn't included in `ActiveRecord::Base` anymore. That's the reason we cannot use `Redmine::Acts::Event#acts_as_event`. Before Redmine v5.1, `ActiveRecord::Base` included `Redmine::Acts::Event`. And `ActiveRecord::Base` was a base class. https://github.com/redmine/redmine/blob/ed7873a4c49d9209c597378dab9a982391093c32/lib/plugins/acts_as_event/init.rb#L4 After Redmine master, `ApplicationRecord` included `Redmine::Acts::Event`. And `ApplicationRecord` was a base class. https://github.com/redmine/redmine/blob/fb449c77bc76b3bae9b3f0bfe18560b11f00902c/lib/plugins/acts_as_event/init.rb#L22 ## Solution Change the base class from ActiveRecord::Base to ApplicationRecord. --------- Co-authored-by: Sutou Kouhei <[email protected]>
1 parent aead520 commit eaddeb1

File tree

7 files changed

+12
-6
lines changed

7 files changed

+12
-6
lines changed

app/models/application_record.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# For backward compatibility with Redmine < 6.
2+
# ApplicationRecord is inherited from ActiveRecord Models instead of ActiveRecord::Base in Redmine >= 6.
3+
# ref: https://www.redmine.org/issues/38975
4+
unless defined?(ApplicationRecord)
5+
ApplicationRecord = ActiveRecord::Base
6+
end

app/models/fts_query_expansion.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class FtsQueryExpansion < ActiveRecord::Base
1+
class FtsQueryExpansion < ApplicationRecord
22
if respond_to?(:connection_db_config)
33
adapter = connection_db_config.adapter
44
else
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module FullTextSearch
2-
class IssueContent < ActiveRecord::Base
2+
class IssueContent < ApplicationRecord
33
end
44
end

app/models/full_text_search/tag.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module FullTextSearch
2-
class Tag < ActiveRecord::Base
2+
class Tag < ApplicationRecord
33
self.table_name = :fts_tags
44
belongs_to :type, class_name: "FullTextSearch::TagType"
55

app/models/full_text_search/tag_type.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module FullTextSearch
2-
class TagType < ActiveRecord::Base
2+
class TagType < ApplicationRecord
33
self.table_name = :fts_tag_types
44
has_many :tags, foreign_key: "type_id"
55

app/models/full_text_search/target.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module FullTextSearch
2-
class Target < ActiveRecord::Base
2+
class Target < ApplicationRecord
33
self.table_name = :fts_targets
44

55
if respond_to?(:connection_db_config)

app/models/full_text_search/type.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module FullTextSearch
2-
class Type < ActiveRecord::Base
2+
class Type < ApplicationRecord
33
self.table_name = :fts_types
44

55
class << self

0 commit comments

Comments
 (0)