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

Changeset 4129

Show
Ignore:
Timestamp:
04/01/06 23:15:35 (2 years ago)
Author:
rick
Message:

Private ActiveRecord methods add_limit, add_joins, and add_conditions take an OPTIONAL third argument 'scope' (closes #4456) [Rick]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/CHANGELOG

    r4124 r4129  
    11*SVN* 
     2 
     3* Private ActiveRecord methods add_limit!, add_joins!, and add_conditions! take an OPTIONAL third argument 'scope' (closes #4456) [Rick] 
    24 
    35* DEPRECATED: Using additional attributes on has_and_belongs_to_many associations. Instead upgrade your association to be a real join model [DHH] 
  • trunk/activerecord/lib/active_record/base.rb

    r4124 r4129  
    10371037        end 
    10381038 
    1039         def add_limit!(sql, options, scope) 
    1040           if scope 
     1039        # The optional scope argument is for the current :find scope. 
     1040        def add_limit!(sql, options, scope = nil) 
     1041          if scope ||= scope(:find) 
    10411042            options[:limit]  ||= scope[:limit] 
    10421043            options[:offset] ||= scope[:offset] 
     
    10451046        end 
    10461047 
    1047         def add_joins!(sql, options, scope) 
     1048        # The optional scope argument is for the current :find scope. 
     1049        def add_joins!(sql, options, scope = nil) 
     1050          scope ||= scope(:find) 
    10481051          join = (scope && scope[:joins]) || options[:joins] 
    10491052          sql << " #{join} " if join 
     
    10511054 
    10521055        # Adds a sanitized version of +conditions+ to the +sql+ string. Note that the passed-in +sql+ string is changed. 
    1053         def add_conditions!(sql, conditions, scope) 
     1056        # The optional scope argument is for the current :find scope. 
     1057        def add_conditions!(sql, conditions, scope = nil) 
     1058          scope  ||= scope(:find) 
    10541059          segments = [] 
    10551060          segments << sanitize_sql(scope[:conditions]) if scope && scope[:conditions]