Skip to content

Commit

Permalink
[#1] Added an extra constraint to the bottom_item method to filter ou…
Browse files Browse the repository at this point in the history
…t any null records. Postgres will order any items removed from the list at the top, which breaks this method when using acts_as_list with postgres.
  • Loading branch information
Daniel Rice committed Aug 16, 2011
1 parent 819c37d commit 286a3e0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/acts_as_list/active_record/acts/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,11 @@ def bottom_position_in_list(except = nil)
item ? item.send(position_column) : acts_as_list_top - 1
end

# Returns the bottom item
# Returns the bottom item contained within the list.
def bottom_item(except = nil)
conditions = scope_condition
conditions = "#{conditions} AND #{self.class.primary_key} != #{except.id}" if except
conditions = "#{conditions} AND #{position_column} IS NOT NULL"
acts_as_list_class.find(:first, :conditions => conditions, :order => "#{position_column} DESC")
end

Expand Down

0 comments on commit 286a3e0

Please sign in to comment.