aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/spawn_methods.rb
diff options
context:
space:
mode:
authorJordi Romero <jordi@jrom.net>2011-01-15 01:15:05 +0100
committerJordi Romero <jordi@jrom.net>2011-01-15 01:17:53 +0100
commitb31ef7ee83f3fe808f7534172ce2bf22ef6c7cc0 (patch)
treee0e09fc7ff87155ff410ca865ab034686662fd7d /activerecord/lib/active_record/relation/spawn_methods.rb
parentda82b0a746c36ea1274041b0d2401903abf33904 (diff)
downloadrails-b31ef7ee83f3fe808f7534172ce2bf22ef6c7cc0.tar.gz
rails-b31ef7ee83f3fe808f7534172ce2bf22ef6c7cc0.tar.bz2
rails-b31ef7ee83f3fe808f7534172ce2bf22ef6c7cc0.zip
document ActiveRecord's except and only
Document methods that allow easily override arel queries
Diffstat (limited to 'activerecord/lib/active_record/relation/spawn_methods.rb')
-rw-r--r--activerecord/lib/active_record/relation/spawn_methods.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation/spawn_methods.rb b/activerecord/lib/active_record/relation/spawn_methods.rb
index 5acf3ec83a..ae777208db 100644
--- a/activerecord/lib/active_record/relation/spawn_methods.rb
+++ b/activerecord/lib/active_record/relation/spawn_methods.rb
@@ -61,6 +61,13 @@ module ActiveRecord
alias :& :merge
+ # Removes from the query the condition(s) specified in +skips+.
+ #
+ # Example:
+ #
+ # Post.order('id asc').except(:order) # discards the order condition
+ # Post.where('id > 10').order('id asc').except(:where) # discards the where condition but keeps the order
+ #
def except(*skips)
result = self.class.new(@klass, table)
@@ -75,6 +82,13 @@ module ActiveRecord
result
end
+ # Removes any condition from the query other than the one(s) specified in +onlies+.
+ #
+ # Example:
+ #
+ # Post.order('id asc').only(:where) # discards the order condition
+ # Post.order('id asc').only(:where, :order) # uses the specified order
+ #
def only(*onlies)
result = self.class.new(@klass, table)