1. 29 8月, 2013 2 次提交
  2. 03 8月, 2013 1 次提交
  3. 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
  4. 20 12月, 2012 1 次提交
  5. 05 10月, 2012 2 次提交
  6. 02 8月, 2012 1 次提交
  7. 20 7月, 2012 1 次提交
  8. 13 7月, 2012 1 次提交
  9. 30 3月, 2012 1 次提交
  10. 17 1月, 2012 2 次提交
  11. 29 12月, 2011 1 次提交
  12. 02 7月, 2011 1 次提交
  13. 01 3月, 2011 1 次提交