1. 10 6月, 2014 1 次提交
  2. 25 5月, 2014 1 次提交
  3. 21 2月, 2014 1 次提交
  4. 15 2月, 2014 2 次提交
  5. 13 12月, 2013 1 次提交
  6. 07 12月, 2013 1 次提交
  7. 17 11月, 2013 1 次提交
  8. 14 10月, 2013 2 次提交
  9. 03 10月, 2013 1 次提交
  10. 24 7月, 2013 1 次提交
  11. 02 7月, 2013 1 次提交
  12. 28 6月, 2013 1 次提交
    • J
      Simplify/fix implementation of default scopes · 94924dc3
      Jon Leighton 提交于
      The previous implementation was necessary in order to support stuff
      like:
      
          class Post < ActiveRecord::Base
            default_scope where(published: true)
            scope :ordered, order("created_at")
          end
      
      If we didn't evaluate the default scope at the last possible moment
      before sending the SQL to the database, it would become impossible to
      do:
      
          Post.unscoped.ordered
      
      This is because the default scope would already be bound up in the
      "ordered" scope, and therefore wouldn't be removed by the
      "Post.unscoped" part.
      
      In 4.0, we have deprecated all "eager" forms of scopes. So now you must
      write:
      
          class Post < ActiveRecord::Base
            default_scope { where(published: true) }
            scope :ordered, -> { order("created_at") }
          end
      
      This prevents the default scope getting bound up inside the "ordered"
      scope, which means we can now have a simpler/better/more natural
      implementation of default scoping.
      
      A knock on effect is that some things that didn't work properly now do.
      For example it was previously impossible to use #except to remove a part
      of the default scope, since the default scope was evaluated after the
      call to #except.
      94924dc3
  13. 23 5月, 2013 1 次提交
  14. 10 5月, 2013 1 次提交
    • J
      Set the inverse when association queries are refined · d7abe91c
      Jon Leighton 提交于
      Suppose Man has_many interests, and inverse_of is used.
      
      Man.first.interests.first.man will correctly execute two queries,
      avoiding the need for a third query when Interest#man is called. This is
      because CollectionAssociation#first calls set_inverse_instance.
      
      However Man.first.interests.where("1=1").first.man will execute three
      queries, even though this is obviously a subset of the records in the
      association.
      
      This is because calling where("1=1") spawns a new Relation object from
      the CollectionProxy object, and the Relation has no knowledge of the
      association, so it cannot set the inverse instance.
      
      This commit solves the problem by making relations spawned from
      CollectionProxies return a new Relation subclass called
      AssociationRelation, which does know about associations. Records loaded
      from this class will get the inverse instance set properly.
      
      Fixes #5717.
      
      Live commit from La Conf! 
      d7abe91c
  15. 03 5月, 2013 1 次提交
    • O
      Do not overwrite manually built records during one-to-one nested attribute assignment · 534030cf
      Olek Janiszewski 提交于
      For one-to-one nested associations, if you build the new (in-memory)
      child object yourself before assignment, then the NestedAttributes
      module will not overwrite it, e.g.:
      
          class Member < ActiveRecord::Base
            has_one :avatar
            accepts_nested_attributes_for :avatar
      
            def avatar
              super || build_avatar(width: 200)
            end
          end
      
          member = Member.new
          member.avatar_attributes = {icon: 'sad'}
          member.avatar.width # => 200
      534030cf
  16. 01 4月, 2013 1 次提交
    • M
      fix inverse_of association in block of new child · 44838159
      Michal Cichra 提交于
      This fixes inconsistency when building children of association
      which has inverse_of set properly.
      
      When creating new association object with a block:
      
          parent.association.build do |child|
            child.parent.equal?(parent) # false
          end
      
      So the block the `child.parent` did not point to the same object.
      But when the object is created it points to same instance:
      
          child = parent.association.build
          child.parent.equal?(parent) # true
      44838159
  17. 30 3月, 2013 4 次提交
  18. 21 3月, 2013 1 次提交
  19. 26 2月, 2013 1 次提交
  20. 22 11月, 2012 1 次提交
  21. 30 10月, 2012 1 次提交
  22. 29 10月, 2012 1 次提交
  23. 24 10月, 2012 1 次提交
  24. 26 9月, 2012 1 次提交
  25. 17 9月, 2012 1 次提交
  26. 06 8月, 2012 1 次提交
  27. 03 8月, 2012 2 次提交
  28. 02 8月, 2012 2 次提交
  29. 28 7月, 2012 1 次提交
  30. 21 7月, 2012 1 次提交
  31. 13 7月, 2012 2 次提交
  32. 24 5月, 2012 1 次提交
    • V
      Revert "Remove blank trailing comments" · 1ad0b378
      Vijay Dev 提交于
      This reverts commit fa6d921e.
      
      Reason: Not a fan of such massive changes. We usually close such changes
      if made to Rails master as a pull request. Following the same principle
      here and reverting.
      
      [ci skip]
      1ad0b378