diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2005-10-20 14:53:04 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2005-10-20 14:53:04 +0000 |
commit | 7219e82fe600ff1268b9a89efc7a289ac0108592 (patch) | |
tree | a50c3c540134016eac18dc0dfeee4874459c7b46 /activerecord/lib | |
parent | 07bff0b535941c6a52555466d1e412f2b9305231 (diff) | |
download | rails-7219e82fe600ff1268b9a89efc7a289ac0108592.tar.gz rails-7219e82fe600ff1268b9a89efc7a289ac0108592.tar.bz2 rails-7219e82fe600ff1268b9a89efc7a289ac0108592.zip |
HABTM finder sets :readonly => false. Closes #2525.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2694 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb | 1 | ||||
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 8 |
2 files changed, 6 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb index 1fab50418a..1b7adc3f39 100644 --- a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb +++ b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb @@ -45,6 +45,7 @@ module ActiveRecord end options[:conditions] = conditions options[:joins] = @join_sql + options[:readonly] ||= false if options[:order] && @options[:order] options[:order] = "#{options[:order]}, #{@options[:order]}" diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 5d594c61a6..aee5c4ede8 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -357,7 +357,7 @@ module ActiveRecord #:nodoc: # * <tt>:offset</tt>: An integer determining the offset from where the rows should be fetched. So at 5, it would skip the first 4 rows. # * <tt>:joins</tt>: An SQL fragment for additional joins like "LEFT JOIN comments ON comments.post_id = id". (Rarely needed). # The records will be returned read-only since they will have attributes that do not correspond to the table's columns. - # Use <tt>find_by_sql</tt> to circumvent this limitation. + # Pass :readonly => false to override. # * <tt>:include</tt>: Names associations that should be loaded alongside using LEFT OUTER JOINs. The symbols named refer # to already defined associations. See eager loading under Associations. # * <tt>:select</tt>: By default, this is * as in SELECT * FROM, but can be changed if you for example want to do a join, but not @@ -384,8 +384,10 @@ module ActiveRecord #:nodoc: def find(*args) options = extract_options_from_args!(args) - # :joins implies :readonly => true - options[:readonly] = true if options[:joins] + # :joins implies :readonly => true if unset. + if options[:joins] and !options.has_key?(:readonly) + options[:readonly] = true + end case args.first when :first |