Changeset 7182
- Timestamp:
- 07/11/07 23:54:43 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/CHANGELOG
r7167 r7182 1 1 *SVN* 2 3 * Make create! on a has_many :through association return the association object. Not the collection. Closes #8786 [lifofifo] 2 4 3 5 * Move from select * to select tablename.* to avoid clobbering IDs. Closes #8889 [dasil003] trunk/activerecord/lib/active_record/associations/has_many_through_association.rb
r6909 r7182 92 92 def create!(attrs = nil) 93 93 @reflection.klass.transaction do 94 self << @reflection.klass.send(:with_scope, :create => attrs) { @reflection.klass.create! } 94 self << (object = @reflection.klass.send(:with_scope, :create => attrs) { @reflection.klass.create! }) 95 object 95 96 end 96 97 end trunk/activerecord/test/associations/join_model_test.rb
r7119 r7182 423 423 assert_equal(count + 1, post_thinking.tags(true).size) 424 424 425 assert_ nothing_raised { post_thinking.tags.create!(:name => 'foo') }425 assert_kind_of Tag, post_thinking.tags.create!(:name => 'foo') 426 426 assert_nil( wrong = post_thinking.tags.detect { |t| t.class != Tag }, 427 427 message = "Expected a Tag in tags collection, got #{wrong.class}.")