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

Changeset 8989

Show
Ignore:
Timestamp:
03/07/08 11:45:07 (2 months ago)
Author:
pratik
Message:

Add :readonly option to HasManyThrough associations. Closes #11156 [miloops]

Files:

Legend:

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

    r8977 r8989  
    11*SVN* 
     2 
     3* Add :readonly option to HasManyThrough associations. #11156 [miloops] 
    24 
    35* Improve performance on :include/:conditions/:limit queries by selectively joining in the pre-query.  #9560 [dasil003] 
  • trunk/activerecord/lib/active_record/associations/has_many_through_association.rb

    r8957 r8989  
    160160            :limit      => @reflection.options[:limit], 
    161161            :group      => @reflection.options[:group], 
     162            :readonly   => @reflection.options[:readonly], 
    162163            :include    => @reflection.options[:include] || @reflection.source_reflection.options[:include] 
    163164          ) 
     
    254255                         :select      => construct_select, 
    255256                         :order       => @reflection.options[:order], 
    256                          :limit       => @reflection.options[:limit] } } 
     257                         :limit       => @reflection.options[:limit], 
     258                         :readonly    => @reflection.options[:readonly], 
     259             } } 
    257260        end 
    258261 
  • trunk/activerecord/test/cases/associations_test.rb

    r8864 r8989  
    555555  end 
    556556 
     557  def test_cant_save_has_many_readonly_association 
     558    authors(:david).readonly_comments.each { |c| assert_raise(ActiveRecord::ReadOnlyRecord) { c.save! } } 
     559    authors(:david).readonly_comments.each { |c| assert c.readonly? } 
     560  end 
     561 
    557562  def test_triple_equality 
    558563    assert !(Array === Firm.find(:first).clients) 
  • trunk/activerecord/test/models/author.rb

    r8790 r8989  
    2121  has_many :ordered_uniq_comments, :through => :posts, :source => :comments, :uniq => true, :order => 'comments.id' 
    2222  has_many :ordered_uniq_comments_desc, :through => :posts, :source => :comments, :uniq => true, :order => 'comments.id DESC' 
    23  
     23  has_many :readonly_comments, :through => :posts, :source => :comments, :readonly => true 
     24   
    2425  has_many :special_posts 
    2526  has_many :special_post_comments, :through => :special_posts, :source => :comments