aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/query_methods.rb
diff options
context:
space:
mode:
authorOscar Del Ben <oscar@oscardelben.com>2012-07-07 13:53:38 -0700
committerOscar Del Ben <oscar@oscardelben.com>2012-07-07 13:53:38 -0700
commite68f63e6048aae61954904125b33e02a6c8934e5 (patch)
treed64d2f7ec3b3589bbfa8f7f96777a2794837da8f /activerecord/lib/active_record/relation/query_methods.rb
parent8e7470adcbce7c278f668ea671dfbcaf089114eb (diff)
downloadrails-e68f63e6048aae61954904125b33e02a6c8934e5.tar.gz
rails-e68f63e6048aae61954904125b33e02a6c8934e5.tar.bz2
rails-e68f63e6048aae61954904125b33e02a6c8934e5.zip
Add docs for having, lock and readonly
Diffstat (limited to 'activerecord/lib/active_record/relation/query_methods.rb')
-rw-r--r--activerecord/lib/active_record/relation/query_methods.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb
index 00030b9e1f..57f80d383e 100644
--- a/activerecord/lib/active_record/relation/query_methods.rb
+++ b/activerecord/lib/active_record/relation/query_methods.rb
@@ -359,6 +359,10 @@ module ActiveRecord
self
end
+ # Allows to specify a HAVING clause. Note that you can't use HAVING
+ # without also specifying a GROUP clause.
+ #
+ # Order.having('SUM(price) > 30').group('user_id')
def having(opts, *rest)
opts.blank? ? self : spawn.having!(opts, *rest)
end
@@ -400,6 +404,8 @@ module ActiveRecord
self
end
+ # Specifies locking settings (default to +true+). For more information
+ # on locking, please see +ActiveRecord::Locking+.
def lock(locks = true)
spawn.lock!(locks)
end
@@ -448,6 +454,12 @@ module ActiveRecord
scoped.extending(NullRelation)
end
+ # Sets readonly attributes for the returned relation. If value is
+ # true (default), attempting to update a record will result in an error.
+ #
+ # users = User.readonly
+ # users.first.save
+ # => ActiveRecord::ReadOnlyRecord: ActiveRecord::ReadOnlyRecord
def readonly(value = true)
spawn.readonly!(value)
end