1. 22 3月, 2012 2 次提交
    • J
      Deprecate eager-evaluated scopes. · 0a12a5f8
      Jon Leighton 提交于
      Don't use this:
      
          scope :red, where(color: 'red')
          default_scope where(color: 'red')
      
      Use this:
      
          scope :red, -> { where(color: 'red') }
          default_scope { where(color: 'red') }
      
      The former has numerous issues. It is a common newbie gotcha to do
      the following:
      
          scope :recent, where(published_at: Time.now - 2.weeks)
      
      Or a more subtle variant:
      
          scope :recent, -> { where(published_at: Time.now - 2.weeks) }
          scope :recent_red, recent.where(color: 'red')
      
      Eager scopes are also very complex to implement within Active
      Record, and there are still bugs. For example, the following does
      not do what you expect:
      
          scope :remove_conditions, except(:where)
          where(...).remove_conditions # => still has conditions
      0a12a5f8
    • J
      Remove valid_scope_name? check - use ruby · f6db31ec
      Jon Leighton 提交于
      scope is syntactic sugar for defining a class method. Ruby allows
      redefining methods but emits a warning when run with -w. So let's
      not implement our own logic for this. Users should run with -w if they
      want to be warned about redefined methods.
      f6db31ec
  2. 19 3月, 2012 1 次提交
  3. 18 3月, 2012 2 次提交
  4. 17 3月, 2012 1 次提交
  5. 16 3月, 2012 3 次提交
  6. 15 3月, 2012 1 次提交
  7. 14 3月, 2012 2 次提交
  8. 13 3月, 2012 1 次提交
  9. 12 3月, 2012 2 次提交
  10. 09 3月, 2012 3 次提交
  11. 08 3月, 2012 3 次提交
  12. 07 3月, 2012 6 次提交
  13. 06 3月, 2012 4 次提交
  14. 05 3月, 2012 1 次提交
  15. 04 3月, 2012 7 次提交
  16. 03 3月, 2012 1 次提交