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

Changeset 4618

Show
Ignore:
Timestamp:
07/24/06 04:55:16 (2 years ago)
Author:
rick
Message:

Allow #count through a has_many association to accept :include. [Dan Peterson]

Files:

Legend:

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

    r4606 r4618  
    11*SVN* 
     2 
     3* Allow #count through a has_many association to accept :include.  [Dan Peterson] 
    24 
    35* create_table rdoc: suggest :id => false for habtm join tables. [Zed Shaw] 
  • trunk/activerecord/lib/active_record/associations.rb

    r4615 r4618  
    1818  class HasManyThroughAssociationPolymorphicError < ActiveRecordError #:nodoc: 
    1919    def initialize(owner_class_name, reflection, source_reflection) 
    20       source_reflection = source_reflection 
    2120      super("Cannot have a has_many :through association '#{owner_class_name}##{reflection.name}' on the polymorphic object '#{source_reflection.class_name}##{source_reflection.name}'.") 
    2221    end 
  • trunk/activerecord/lib/active_record/associations/has_many_association.rb

    r4416 r4618  
    4949            @finder_sql : 
    5050            @finder_sql + " AND (#{sanitize_sql(options[:conditions])})" 
     51          options[:include] = @reflection.options[:include] 
    5152 
    5253          @reflection.klass.count(column_name, options) 
  • trunk/activerecord/test/associations_go_eager_test.rb

    r4232 r4618  
    357357    assert_equal 2, one.categories.size 
    358358  end 
     359   
     360  def test_count_with_include 
     361    assert_equal 3, authors(:david).posts_with_comments.count(:conditions => "length(comments.body) > 15") 
     362  end 
    359363end