Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix position when no serial positions #223

Merged
merged 5 commits into from
Aug 21, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'master' into fix-not-serial-positions
Conflicts:
	lib/acts_as_list/active_record/acts/list.rb
  • Loading branch information
jpalumickas committed Aug 19, 2016
commit 4dca66db24d013cb811ac7b5b42ab4722f92d2e6
10 changes: 6 additions & 4 deletions lib/acts_as_list/active_record/acts/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,10 @@ def self.update_all_with_touch(updates)
attr_reader :position_changed

before_validation :check_top_position

before_destroy :lock!
after_destroy :decrement_positions_on_lower_items

before_update :check_scope
after_update :update_positions

Expand Down Expand Up @@ -264,8 +266,8 @@ def higher_items(limit=nil)
limit ||= acts_as_list_list.count
position_value = send(position_column)
acts_as_list_list.
where("#{quoted_table_name}.#{quoted_position_column} < ?", position_value).
order("#{quoted_table_name}.#{quoted_position_column} DESC").
where("#{quoted_position_column_with_table_name} < ?", position_value).
order("#{quoted_position_column_with_table_name} DESC").
limit(limit)
end

Expand All @@ -281,8 +283,8 @@ def lower_items(limit=nil)
limit ||= acts_as_list_list.count
position_value = send(position_column)
acts_as_list_list.
where("#{quoted_table_name}.#{quoted_position_column} > ?", position_value).
order("#{quoted_table_name}.#{quoted_position_column} ASC").
where("#{quoted_position_column_with_table_name} > ?", position_value).
order("#{quoted_position_column_with_table_name} ASC").
limit(limit)
end

Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.