diff options
author | Vijay Dev <vijaydev.cse@gmail.com> | 2012-06-22 22:15:27 +0530 |
---|---|---|
committer | Vijay Dev <vijaydev.cse@gmail.com> | 2012-06-22 22:15:27 +0530 |
commit | 35ee8fa3d8b3ad49179f86af2bec2e53af335ac9 (patch) | |
tree | 5929e772a461c683c54c1fd66b303516e5d0df33 /activerecord | |
parent | fb8cf55868d555b7f06215db5976c8aaf083d30b (diff) | |
parent | 6285675db1cf983ba6c15442aedb457c8041f5ee (diff) | |
download | rails-35ee8fa3d8b3ad49179f86af2bec2e53af335ac9.tar.gz rails-35ee8fa3d8b3ad49179f86af2bec2e53af335ac9.tar.bz2 rails-35ee8fa3d8b3ad49179f86af2bec2e53af335ac9.zip |
Merge branch 'master' of github.com:lifo/docrails
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/callbacks.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 18 |
2 files changed, 16 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/callbacks.rb b/activerecord/lib/active_record/callbacks.rb index cc11567506..111208d0b9 100644 --- a/activerecord/lib/active_record/callbacks.rb +++ b/activerecord/lib/active_record/callbacks.rb @@ -34,7 +34,7 @@ module ActiveRecord # Examples: # class CreditCard < ActiveRecord::Base # # Strip everything but digits, so the user can specify "555 234 34" or - # # "5552-3434" or both will mean "55523434" + # # "5552-3434" and both will mean "55523434" # before_validation(:on => :create) do # self.number = number.gsub(/[^0-9]/, "") if attribute_present?("number") # end diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index e394acfaf2..5e5aca0396 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -73,8 +73,6 @@ module ActiveRecord # Used to indicate that an association is referenced by an SQL string, and should # therefore be JOINed in any query rather than loaded separately. # - # For example: - # # User.includes(:posts).where("posts.name = 'foo'") # # => Doesn't JOIN the posts table, resulting in an error. # @@ -165,7 +163,6 @@ module ActiveRecord # User.order('email DESC').reorder('id ASC').order('name ASC') # # generates a query with 'ORDER BY id ASC, name ASC'. - # def reorder(*args) args.blank? ? self : spawn.reorder!(*args) end @@ -310,6 +307,11 @@ module ActiveRecord self end + # Specifies a limit for the number of records to retrieve. + # + # User.limit(10) # generated SQL has 'LIMIT 10' + # + # User.limit(10).limit(20) # generated SQL has 'LIMIT 20' def limit(value) spawn.limit!(value) end @@ -319,6 +321,13 @@ module ActiveRecord self end + # Specifies the number of rows to skip before returning rows. + # + # User.offset(10) # generated SQL has "OFFSET 10" + # + # Should be used with order. + # + # User.offset(10).order("name ASC") def offset(value) spawn.offset!(value) end @@ -488,6 +497,9 @@ module ActiveRecord self end + # Reverse the existing order clause on the relation. + # + # User.order('name ASC').reverse_order # generated SQL has 'ORDER BY name DESC' def reverse_order spawn.reverse_order! end |