Skip to content

Commit

Permalink
Simplify composite primary_key_condition
Browse files Browse the repository at this point in the history
  • Loading branch information
brendon committed Aug 2, 2024
1 parent c1b980c commit 07f6c27
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/acts_as_list/active_record/acts/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,8 @@ def active_record_version_is?(version_requirement)
requirement.satisfied_by?(version)
end

def primary_key_condition(id = nil)
primary_keys = Array.wrap(self.class.primary_key)
id ? primary_keys.zip(Array.wrap(id)).to_h : slice(*primary_keys)
def primary_key_condition(id = self.id)
{ self.class.primary_key => [id] }
end
end

Expand Down

0 comments on commit 07f6c27

Please sign in to comment.