Skip to content
This repository has been archived by the owner on Apr 2, 2021. It is now read-only.

Commit

Permalink
Fallback when previous_value doesn't respond to #next.
Browse files Browse the repository at this point in the history
For example, floating point attributes won't respond to #next, so in
this case fall back to adding 1. This is not perfect, but it seems
to rarely occur in practice since I wasn't able to find anyone else
complaining about it.
  • Loading branch information
sjmadsen committed Sep 20, 2011
1 parent 3d94390 commit 9d0c74e
Showing 1 changed file with 5 additions and 1 deletion.
Expand Up @@ -116,7 +116,11 @@ def validate_after_scope_change
# Assume the scope is a foreign key if the field is nil
previous_value ||= 0

next_value = previous_value.next
next_value = if previous_value.respond_to?(:next)
previous_value.next
else
previous_value + 1
end

@subject.send("#{scope}=", next_value)

Expand Down

0 comments on commit 9d0c74e

Please sign in to comment.