1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
Commit graph

8 commits

Author SHA1 Message Date
Rafael Mendonça França
c26a690b99 Merge pull request #14573 from habermann24/has_many_through_fix
Properly handle scoping with has_many :through. Fixes #14537.

Conflicts:
	activerecord/CHANGELOG.md
	activerecord/test/cases/associations/has_many_through_associations_test.rb
2014-04-22 17:20:52 -05:00
Jan Habermann
98e69078d5 Properly handle scoping with has_many :through. Fixes #14537. 2014-04-03 01:52:42 +02:00
Jon Leighton
c8d889905d Prevent Relation#merge from collapsing wheres on the RHS
This caused a bug with the new associations implementation, because now
association conditions are represented as Arel nodes internally right up
to when the whole thing gets turned to SQL.

In Rails 3.2, association conditions get turned to raw SQL early on,
which prevents Relation#merge from interfering.

The current implementation was buggy when a default_scope existed on the
target model, since we would basically end up doing:

  default_scope.merge(association_scope)

If default_scope contained a where(foo: 'a') and association_scope
contained a where(foo: 'b').where(foo: 'c') then the merger would see
that the same column is representated on both sides of the merge and
collapse the wheres to all but the last: where(foo: 'c')

Now, the RHS of the merge is left alone.

Fixes #8990
2013-01-27 20:34:52 +00:00
Guillermo Iguaran
8020f71df1 Remove mass assignment security from ActiveRecord 2012-09-16 23:58:19 -05:00
Pratik Naik
754173c5ff Add a test to make sure preloading properly merges association and default scope conditions 2012-08-28 12:49:55 -07:00
Rafael Mendonça França
c9c7ee7710 Not need to pass join attributes to association build 2012-03-07 21:07:29 -03:00
Jon Leighton
91fd651056 Allow building and then later saving has_many :through records, such that the join record is automatically saved too. This requires the :inverse_of option to be set on the source association in the join model. See the CHANGELOG for details. [#4329 state:resolved] 2011-02-18 00:00:13 +00:00
Jeremy Kemper
43b81d01d0 move assets and models
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8657 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-01-18 07:27:03 +00:00
Renamed from activerecord/test/fixtures/reader.rb (Browse further)