Skip to content

Commit

Permalink
More reliable lower/higher item detection
Browse files Browse the repository at this point in the history
  • Loading branch information
miks committed Nov 15, 2012
1 parent d8c24c0 commit 547b65e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/acts_as_list/active_record/acts/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,15 @@ def last?
def higher_item
return nil unless in_list?
acts_as_list_class.unscoped.find(:first, :conditions =>
"#{scope_condition} AND #{position_column} = #{(send(position_column).to_i - 1).to_s}"
"#{scope_condition} AND #{position_column} < #{(send(position_column).to_i).to_s}"
)
end

# Return the next lower item in the list.
def lower_item
return nil unless in_list?
acts_as_list_class.unscoped.find(:first, :conditions =>
"#{scope_condition} AND #{position_column} = #{(send(position_column).to_i + 1).to_s}"
"#{scope_condition} AND #{position_column} > #{(send(position_column).to_i).to_s}"
)
end

Expand Down

0 comments on commit 547b65e

Please sign in to comment.