Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #3887 (closed enhancement: fixed)

Opened 4 years ago

Last modified 3 years ago

[PATCH] Add :order capability to with_scope in ActiveRecord

Reported by: eric.daspet@survol.net Assigned to: David
Priority: normal Milestone:
Component: ActiveRecord Version: 1.0.0
Severity: normal Keywords:
Cc:

Description

This patch adds :order to the with_scope method within ActiveRecord::Base for find().

This will be helpful to define shorthands with conditions, limits and orders in the model (and not specify order with the sql column name each time when we use find()).

somethine like :

def in_most_recents(nbr=5) 
  with_scope(:limit => nbr, :order => 'publicated_at DESC', :conditions => 'publicated = 1') do
    yield
  end
end

Attachments

scope_order_patch.diff (3.4 kB) - added by eric.daspet@survol.net on 02/19/06 14:27:45.
patch (test included) to add :order to with_scope ine ActiveRecord::Base
scope_order_path.diff (3.6 kB) - added by eric.daspet@survol.net on 02/27/06 09:09:06.
(update after nested scope commit, done against last trunk r3686) patch (test included) to add :order to with_scope ine ActiveRecord?::Base

Change History

02/19/06 14:27:45 changed by eric.daspet@survol.net

  • attachment scope_order_patch.diff added.

patch (test included) to add :order to with_scope ine ActiveRecord::Base

02/26/06 20:13:59 changed by david

Needs to be updated now that nested scopes was applied.

02/27/06 09:09:06 changed by eric.daspet@survol.net

  • attachment scope_order_path.diff added.

(update after nested scope commit, done against last trunk r3686) patch (test included) to add :order to with_scope ine ActiveRecord?::Base

04/26/06 06:37:14 changed by marcel

  • status changed from new to closed.
  • resolution set to fixed.

(In [4274]) Add support for :order option to with_scope. Closes #3887. [eric.daspet@survol.net]

08/21/06 15:54:09 changed by kastberg@tkwsping.nl

  • status changed from reopened to closed.
  • resolution set to fixed.

spammer