diff options
author | Vijay Dev <vijaydev.cse@gmail.com> | 2012-01-11 20:18:55 +0530 |
---|---|---|
committer | Vijay Dev <vijaydev.cse@gmail.com> | 2012-01-11 20:18:55 +0530 |
commit | 7c29246b8c810ca7b736ad8a28bc94b4a22d22da (patch) | |
tree | a4e2d357cb5274d7c826ea2beb1f35af30f5a9bf /activerecord | |
parent | 3f8f96e9802c7f628f5b3abd48624e26d97e5ad9 (diff) | |
parent | ce41a368865c341faa0b98b0851b56ba6be6eafb (diff) | |
download | rails-7c29246b8c810ca7b736ad8a28bc94b4a22d22da.tar.gz rails-7c29246b8c810ca7b736ad8a28bc94b4a22d22da.tar.bz2 rails-7c29246b8c810ca7b736ad8a28bc94b4a22d22da.zip |
Merge branch 'master' of github.com:lifo/docrails
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods/primary_key.rb | 3 | ||||
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 10 |
2 files changed, 12 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/primary_key.rb b/activerecord/lib/active_record/attribute_methods/primary_key.rb index a7785f8786..7c59664703 100644 --- a/activerecord/lib/active_record/attribute_methods/primary_key.rb +++ b/activerecord/lib/active_record/attribute_methods/primary_key.rb @@ -44,7 +44,8 @@ module ActiveRecord end # Defines the primary key field -- can be overridden in subclasses. Overwriting will negate any effect of the - # primary_key_prefix_type setting, though. + # primary_key_prefix_type setting, though. Since primary keys are usually protected from mass assignment, + # remember to let your database generate them or include the key in +attr_accessible+. def primary_key @primary_key = reset_primary_key unless defined? @primary_key @primary_key diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 456afbb4cf..44ff8f7b22 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -93,6 +93,16 @@ module ActiveRecord relation end + # Replaces any existing order defined on the relation with the specified order. + # + # User.order('email DESC').reorder('id ASC') # generated SQL has 'ORDER BY id ASC' + # + # Subsequent calls to order on the same relation will be appended. For example: + # + # User.order('email DESC').reorder('id ASC').order('name ASC') + # + # generates a query with 'ORDER BY id ASC, name ASC'. + # def reorder(*args) return self if args.blank? |