1. 02 2月, 2014 1 次提交
  2. 30 1月, 2014 1 次提交
    • G
      `scope` now raises on "dangerous" name conflicts · 7e8e91c4
      Godfrey Chan 提交于
      Similar to dangerous attribute methods, a scope name conflict is
      dangerous if it conflicts with an existing class method defined within
      `ActiveRecord::Base` but not its ancestors.
      
      See also #13389.
      
      *Godfrey Chan*, *Philippe Creux*
      7e8e91c4
  3. 21 1月, 2014 1 次提交
    • J
      Ensure #second acts like #first AR finder · cafe31a0
      Jason Meller 提交于
      This commit bring the famous ordinal Array instance methods defined
      in ActiveSupport into ActiveRecord as fully-fledged finders.
      
      These finders ensure a default ascending order of the table's primary
      key, and utilize the OFFSET SQL verb to locate the user's desired
      record. If an offset is defined in the query, calling #second adds
      to the offset to get the actual desired record.
      
      Fixes #13743.
      cafe31a0
  4. 04 7月, 2013 1 次提交
  5. 02 7月, 2013 1 次提交
  6. 29 6月, 2013 1 次提交
  7. 05 4月, 2013 2 次提交
    • J
      Fix scope chaining + STI · 8606a7fb
      Jon Leighton 提交于
      See #9869 and #9929.
      
      The problem arises from the following example:
      
          class Project < ActiveRecord::Base
            scope :completed, -> { where completed: true }
          end
      
          class MajorProject < Project
          end
      
      When calling:
      
          MajorProject.where(tasks_count: 10).completed
      
      This expands to:
      
          MajorProject.where(tasks_count: 10).scoping {
            MajorProject.completed
          }
      
      However the lambda for the `completed` scope is defined on Project. This
      means that when it is called, `self` is Project rather than
      MajorProject. So it expands to:
      
          MajorProject.where(tasks_count: 10).scoping {
            Project.where(completed: true)
          }
      
      Since the scoping was applied on MajorProject, and not Project, this
      fails to apply the tasks_count condition.
      
      The solution is to make scoping apply across STI classes. I am slightly
      concerned about the possible side-effects of this, but no tests fail and
      it seems ok. I guess we'll see.
      8606a7fb
    • N
      failing test for #9869 · f029fb07
      Neeraj Singh 提交于
      f029fb07
  8. 30 3月, 2013 2 次提交
  9. 28 3月, 2013 1 次提交
  10. 19 3月, 2013 1 次提交
  11. 08 3月, 2013 2 次提交
  12. 03 8月, 2012 1 次提交
    • J
      Remove ActiveRecord::Base.to_a · 55b24888
      Jon Leighton 提交于
      On reflection, it seems like a bit of a weird method to have on
      ActiveRecord::Base, and it shouldn't be needed most of the time anyway.
      55b24888
  13. 28 7月, 2012 1 次提交
  14. 27 7月, 2012 1 次提交
    • J
      ActiveRecord::Base.all returns a Relation. · 6a81ccd6
      Jon Leighton 提交于
      Previously it returned an Array.
      
      If you want an array, call e.g. `Post.to_a` rather than `Post.all`. This
      is more explicit.
      
      In most cases this should not break existing code, since
      Relations use method_missing to delegate unknown methods to #to_a
      anyway.
      6a81ccd6
  15. 10 6月, 2012 2 次提交
  16. 18 5月, 2012 1 次提交
  17. 04 5月, 2012 3 次提交
  18. 27 4月, 2012 6 次提交
  19. 26 4月, 2012 3 次提交
  20. 25 4月, 2012 2 次提交
  21. 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
  22. 12 2月, 2012 1 次提交
  23. 11 2月, 2012 1 次提交
  24. 22 12月, 2011 1 次提交
  25. 17 12月, 2011 1 次提交