Skip to content

Commit

Permalink
rails 5 does not have pick, fixes latest status check
Browse files Browse the repository at this point in the history
  • Loading branch information
orangewolf committed Feb 9, 2024
1 parent c488439 commit 166e212
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/models/bulkrax/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ def self.latest_by_statusable_subtable
end

def latest?
self.id == self.class.where(statusable_id: self.statusable_id, statusable_type: self.statusable_type).order('id desc').pick(:id)
# TODO: remove if statment when we stop supporting Hyrax < 4
self.id == if Gem::Version.new(Rails::VERSION) >= Gem::Version.new('6.0.0')
self.class.where(statusable_id: self.statusable_id, statusable_type: self.statusable_type).order('id desc').pick(:id)
else
self.class.where(statusable_id: self.statusable_id, statusable_type: self.statusable_type).order('id desc').pluck(:id).first
end
end
end
end

0 comments on commit 166e212

Please sign in to comment.