Skip to content

Commit

Permalink
rails v7.0 support
Browse files Browse the repository at this point in the history
  • Loading branch information
gigorok committed Nov 1, 2023
1 parent 642bb62 commit 10132e1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ jobs:
- '5.2.6'
- '6.0.4'
- '6.1.4'
- '7.0.0'
exclude:
- ruby_version: '3.0'
rails_version: '5.2.6'
- ruby_version: '2.6'
rails_version: '7.0.0'

name: Ruby ${{ matrix.ruby_version }} / Rails ${{ matrix.rails_version }}

Expand Down
12 changes: 11 additions & 1 deletion lib/active_admin_import/import_result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,21 @@ def failed_message(options = {})
limit = options[:limit] || failed.count
failed.first(limit).map do |record|
errors = record.errors
failed_values = errors.keys.map do |key|
failed_values = attribute_names_for(errors).map do |key|
key == :base ? nil : record.public_send(key)
end
errors.full_messages.zip(failed_values).map { |ms| ms.compact.join(' - ') }.join(', ')
end.join(' ; ')
end

private

def attribute_names_for(errors)
if Gem::Version.new(Rails.version) >= Gem::Version.new('7.0')
errors.attribute_names
else
errors.keys
end
end
end
end

0 comments on commit 10132e1

Please sign in to comment.