Skip to content

Commit d5d116b

Browse files
committed
Fix Rails 5.1 compatibility: Remove ActiveModel::Attributes
ActiveModel::Attributes is only available in Rails 5.2+. For Rails 5.1 compatibility, use attr_accessor instead. Changes: - Remove 'include ActiveModel::Attributes' - Replace 'attribute :id, :integer' with 'attr_accessor :id' - Add explicit initialize method This ensures the test fixtures work with Rails 5.1.7 and above.
1 parent 26aebdb commit d5d116b

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

test/fixtures/active_record.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2695,11 +2695,14 @@ class RobotResource < ::JSONAPI::Resource
26952695
# ActiveModel class without ActiveRecord
26962696
class SimpleModel
26972697
include ActiveModel::Model
2698-
include ActiveModel::Attributes
26992698

2700-
attribute :id, :integer
2701-
attribute :name, :string
2702-
attribute :description, :string
2699+
attr_accessor :id, :name, :description
2700+
2701+
def initialize(attributes = {})
2702+
@id = attributes[:id]
2703+
@name = attributes[:name]
2704+
@description = attributes[:description]
2705+
end
27032706

27042707
# Simple in-memory store for testing
27052708
@@store = {}

0 commit comments

Comments
 (0)