Skip to content

Commit

Permalink
Fixed the default value issue
Browse files Browse the repository at this point in the history
  • Loading branch information
swanandp committed Aug 11, 2011
1 parent 8e39132 commit e81eb82
Show file tree
Hide file tree
Showing 2 changed files with 615 additions and 3 deletions.
16 changes: 14 additions & 2 deletions lib/acts_as_list/active_record/acts/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,19 @@ def lower_item

# Test if this record is in a list
def in_list?
!send(position_column).nil?
!not_in_list?
end

def not_in_list?
send(position_column).nil?
end

def default_position
acts_as_list_class.columns_hash[position_column.to_s].default
end

def default_position?
default_position == send(position_column)
end

private
Expand All @@ -189,7 +201,7 @@ def add_to_list_top
end

def add_to_list_bottom
if self[position_column].nil?
if not_in_list? || default_position?
self[position_column] = bottom_position_in_list.to_i + 1
else
increment_positions_on_lower_items(self[position_column])
Expand Down
Loading

1 comment on commit e81eb82

@MattRogish
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!

Please sign in to comment.