1. 09 4月, 2015 1 次提交
    • A
      Batch touch parent records · 89713897
      Arthur Neves 提交于
      [fixes #18606]
      
      Make belongs_to use touch over touch_later when running the callbacks.
      
      Add more tests and small method rename
      
      Thanks Jeremy for the feedback.
      89713897
  2. 22 2月, 2015 1 次提交
  3. 27 1月, 2015 1 次提交
  4. 14 11月, 2014 1 次提交
  5. 08 11月, 2014 1 次提交
  6. 29 9月, 2014 1 次提交
    • B
      Isolate access to @associations_cache and @aggregations cache to the... · 9d569585
      Ben Woosley 提交于
      Isolate access to @associations_cache and @aggregations cache to the Associations and Aggregations modules, respectively.
      
      This includes replacing the `association_cache` accessor with a more
      limited `association_cached?` accessor and making `clear_association_cache`
      and `clear_aggregation_cache` private.
      9d569585
  7. 09 7月, 2014 1 次提交
  8. 06 7月, 2014 1 次提交
  9. 28 6月, 2014 3 次提交
  10. 26 6月, 2014 1 次提交
    • S
      Deprecate automatic counter caches on has_many :through · d730e374
      Sean Griffin 提交于
      Reliant on https://github.com/rails/rails/pull/15747 but pulled to a
      separate PR to reduce noise. `has_many :through` associations have the
      undocumented behavior of automatically detecting counter caches.
      However, the way in which it does so is inconsistent with counter caches
      everywhere else, and doesn't actually work consistently.
      
      As with normal `has_many` associations, the user should specify the
      counter cache on the `belongs_to`, if they'd like it updated.
      d730e374
  11. 21 5月, 2014 2 次提交
  12. 14 4月, 2014 2 次提交
  13. 05 4月, 2014 1 次提交
  14. 26 3月, 2014 1 次提交
  15. 18 3月, 2014 1 次提交
  16. 15 3月, 2014 1 次提交
    • W
      Still touch associations when theres no timestamp · ea3a73e7
      Washington Luiz 提交于
      Prior to Rails 4.0.4 when touching a object which doesn't have timestamp
      attributes (updated_at / updated_on) rails would still touch all
      associations. After 73ba2c14 it updates
      associations but rollsback because `touch` would return nil since
      there's no timestamp attribute
      ea3a73e7
  17. 20 2月, 2014 1 次提交
  18. 31 1月, 2014 1 次提交
  19. 22 1月, 2014 1 次提交
  20. 23 12月, 2013 1 次提交
  21. 18 12月, 2013 1 次提交
  22. 29 11月, 2013 1 次提交
  23. 26 10月, 2013 1 次提交
  24. 29 7月, 2013 1 次提交
  25. 05 7月, 2013 2 次提交
  26. 03 6月, 2013 1 次提交
  27. 07 5月, 2013 1 次提交
    • B
      Confirm a record has not already been destroyed before decrementing · 228720ef
      Ben Tucker 提交于
      counter cache
      
      At present, calling destroy multiple times on the same record results
      in the belongs_to counter cache being decremented multiple times. With
      this change the record is checked for whether it is already destroyed
      prior to decrementing the counter cache.
      228720ef
  28. 08 3月, 2013 1 次提交
  29. 07 3月, 2013 1 次提交
  30. 04 1月, 2013 2 次提交
    • J
      Fix undefined method `to_i' introduced since 3.2.8 · 8d98c83b
      Jason Stirk 提交于
      This commit fixes a bug introduced in 96a13fc7 which breaks behaviour of
      integer fields.
      
      In 3.2.8, setting the value of an integer field to a non-integer (eg.
      Array, Hash, etc.) would default to 1 (true) :
      
          # 3.2.8
          p = Post.new
          p.category_id = [ 1, 2 ]
          p.category_id # => 1
          p.category_id = { 3 => 4 }
          p.category_id # => 1
      
      In 3.2.9 and above, this will raise a NoMethodError :
      
          # 3.2.9
          p = Post.new
          p.category_id = [ 1, 2 ]
      
          NoMethodError: undefined method `to_i' for [1, 2]:Array
      
      Whilst at first blush this appear to be sensible, it combines in bad
      ways with scoping.
      
      For example, it is common to use scopes to control access to data :
      
          @collection = Posts.where(:category_id => [ 1, 2 ])
          @new_post = @collection.new
      
      In 3.2.8, this would work as expected, creating a new Post object
      (albeit with @new_post.category_id = 1). However, in 3.2.9 this will
      cause the NoMethodError to be raised as above.
      
      It is difficult to avoid triggering this error without descoping before
      calling .new, breaking any apps running on 3.2.8 that rely on this
      behaviour.
      
      This patch deviates from 3.2.8 in that it does not retain the somewhat
      spurious behaviour of setting the attribute to 1. Instead, it explicitly
      sets these invalid values to nil :
      
          p = Post.new
          p.category_id = [ 1, 2 ]
          p.category_id # => nil
      
      This also fixes the situation where a scope using an array will
      "pollute" any newly instantiated records.
      
          @new_post = @collection.new
          @new_post.category_id # => nil
      
      Finally, 3.2.8 exhibited a behaviour where setting an object to an
      integer field caused it to be coerced to "1". This has not been
      retained, as it is spurious and surprising in the same way that setting
      Arrays and Heshes was :
      
          c = Category.find(6)
          p = Post.new
      
          # 3.2.8
          p.category_id = c
          p.category_id # => 1
      
          # This patch
          p.category_id = c
          p.category_id # => nil
      
      This commit includes explicit test cases that expose the original issue
      with calling new on a scope that uses an Array. As this is a common
      situation, an explicit test case is the best way to prevent regressions
      in the future.
      
      It also updates and separates existing tests to be explicit about the
      situation that is being tested (eg. AR objects vs. other objects vs.
      non-integers)
      8d98c83b
    • A
  31. 02 1月, 2013 1 次提交
  32. 29 11月, 2012 2 次提交
  33. 11 8月, 2012 1 次提交
    • J
      Use method compilation for association methods · 6e57d5c5
      Jon Leighton 提交于
      Method compilation provides better performance and I think the code
      comes out cleaner as well.
      
      A knock on effect is that methods that get redefined produce warnings. I
      think this is a good thing. I had to deal with a bunch of warnings
      coming from our tests, though.
      6e57d5c5