aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-07-05 01:43:47 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-07-05 01:43:47 +0000
commitb272100f05aa3669efe1ad4d0d7b4299a568f1c0 (patch)
tree20c50f0f5c4e2c1259d98329cb1564d1513aaf15 /activerecord/lib
parentf780bb8f58f15f6d60c8d6a4ad4adf19f3681bfe (diff)
downloadrails-b272100f05aa3669efe1ad4d0d7b4299a568f1c0.tar.gz
rails-b272100f05aa3669efe1ad4d0d7b4299a568f1c0.tar.bz2
rails-b272100f05aa3669efe1ad4d0d7b4299a568f1c0.zip
Doc fix (closes #5504) [lee@omara.ca]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4543 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/acts/list.rb16
-rwxr-xr-xactiverecord/lib/active_record/associations.rb1
2 files changed, 15 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/acts/list.rb b/activerecord/lib/active_record/acts/list.rb
index 6d235967c6..87bb1280e1 100644
--- a/activerecord/lib/active_record/acts/list.rb
+++ b/activerecord/lib/active_record/acts/list.rb
@@ -77,7 +77,8 @@ module ActiveRecord
def insert_at(position = 1)
insert_at_position(position)
end
-
+
+ # Swap positions with the next lower item, if one exists.
def move_lower
return unless lower_item
@@ -87,6 +88,7 @@ module ActiveRecord
end
end
+ # Swap positions with the next higher item, if one exists.
def move_higher
return unless higher_item
@@ -96,6 +98,8 @@ module ActiveRecord
end
end
+ # Move to the bottom of the list. If the item is already in the list, the items below it have their
+ # position adjusted accordingly.
def move_to_bottom
return unless in_list?
acts_as_list_class.transaction do
@@ -104,6 +108,8 @@ module ActiveRecord
end
end
+ # Move to the top of the list. If the item is already in the list, the items above it have their
+ # position adjusted accordingly.
def move_to_top
return unless in_list?
acts_as_list_class.transaction do
@@ -111,31 +117,36 @@ module ActiveRecord
assume_top_position
end
end
-
+
def remove_from_list
decrement_positions_on_lower_items if in_list?
end
+ # Increase the position of this item without adjusting the rest of the list.
def increment_position
return unless in_list?
update_attribute position_column, self.send(position_column).to_i + 1
end
+ # Decrease the position of this item without adjusting the rest of the list.
def decrement_position
return unless in_list?
update_attribute position_column, self.send(position_column).to_i - 1
end
+ # Return true if this object is the first in the list.
def first?
return false unless in_list?
self.send(position_column) == 1
end
+ # Return true if this object is the last in the list.
def last?
return false unless in_list?
self.send(position_column) == bottom_position_in_list
end
+ # Return the next higher item in the list.
def higher_item
return nil unless in_list?
acts_as_list_class.find(:first, :conditions =>
@@ -143,6 +154,7 @@ module ActiveRecord
)
end
+ # Return the next lower item in the list.
def lower_item
return nil unless in_list?
acts_as_list_class.find(:first, :conditions =>
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index a059993598..bf03a9bf1a 100755
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -1147,6 +1147,7 @@ module ActiveRecord
add_conditions!(sql, options[:conditions], scope)
add_limited_ids_condition!(sql, options, join_dependency) if !using_limitable_reflections?(join_dependency.reflections) && ((scope && scope[:limit]) || options[:limit])
+ sql << "GROUP BY #{options[:group]} " if options[:group]
sql << "ORDER BY #{options[:order]} " if options[:order]
add_limit!(sql, options, scope) if using_limitable_reflections?(join_dependency.reflections)