1. 11 3月, 2014 1 次提交
    • A
      Fixes STI when 2+ levels deep. · e5f15a83
      Arthur Neves 提交于
      PR #14052 Added a regression where it was only looking for methods in one
      level up, So when the method was defined in a 2+ levels up the
      inheritance chain, the method was not found as defined.
      e5f15a83
  2. 24 2月, 2014 1 次提交
    • G
      Fixed STI classes not defining an attribute method if there is a · 41554319
      Godfrey Chan 提交于
      conflicting private method defined on its ancestors.
      
      The problem is that `method_defined_within?(name, klass, superklass)`
      only works correclty when `klass` and `superklass` are both `Class`es.
      
      If both `klass` and `superklass` are both `Class`es, they share the
      same inheritance chain, so if a method is defined on `klass` but not
      `superklass`, this method must be introduced at some point between
      `klass` and `superklass`.
      
      This does not work when `superklass` is a `Module`. A `Module`'s
      inheritance chain contains just itself. So if a method is defined on
      `klass` but not on `superklass`, the method could still be defined
      somewhere upstream, e.g. in `Object`.
      
      This fix works by avoiding calling `method_defined_within?` with a
      module while still fufilling the requirement (checking that the
      method is defined withing `superclass` but not is not a generated
      attribute method).
      
      4d8ee288 is likely an attempted partial fix for this problem. This
      unrolls that fix and properly check the `superclass` as intended.
      
      Fixes #11569.
      41554319
  3. 30 1月, 2014 2 次提交
  4. 19 12月, 2013 1 次提交
  5. 30 10月, 2013 1 次提交
  6. 25 10月, 2013 1 次提交
  7. 30 9月, 2013 1 次提交
    • T
      Fix AR#method_missing re-dispatching into overwritten attribute methods. · e9bf87f0
      thedarkone 提交于
      This was happening when a `super` call in an overwritten attribute method
      was triggering a method_missing fallback, because attribute methods
      haven't been generated yet.
      
        class Topic < ActiveRecord::Base
          def title
            # `super` would re-invoke this method if define_attribute_methods
            # hasn't been called yet resulting in double '!' appending
            super + '!'
          end
        end
      e9bf87f0
  8. 29 9月, 2013 1 次提交
  9. 16 7月, 2013 1 次提交
  10. 10 7月, 2013 1 次提交
  11. 09 7月, 2013 1 次提交
  12. 04 7月, 2013 3 次提交
  13. 03 7月, 2013 11 次提交
  14. 28 4月, 2013 1 次提交
  15. 26 4月, 2013 2 次提交
  16. 20 4月, 2013 2 次提交
    • X
      if singletons belong to the contract, test them · 0400a7ff
      Xavier Noria 提交于
      Object#respond_to? returns singletons and thus we inherit that contract.
      The implementation of the predicate is good, but the test is only
      checking boolean semantics, which in this case is not enough.
      0400a7ff
    • N
      fix respond_to? for non selected column · 66001f36
      Neeraj Singh 提交于
      fixes #4208
      
      If a query selects only a few columns and gives custom names to
      those columns then respond_to? was returning true for the non
      selected columns. However calling those non selected columns
      raises exception.
      
          post = Post.select("'title' as post_title").first
      
      In the above case when `post.body` is invoked then an exception is
      raised since `body` attribute is not selected. Howevere `respond_to?`
      did not behave correctly.
      
          pos.respond_to?(:body) #=> true
      
      Reason was that Active Record calls `super` to pass the call to
      Active Model and all the columns are defined on Active Model.
      
      Fix is to actually check if the data returned from the db contains
      the data for column in question.
      66001f36
  17. 27 3月, 2013 1 次提交
  18. 22 3月, 2013 1 次提交
  19. 19 3月, 2013 1 次提交
  20. 10 11月, 2012 1 次提交
  21. 29 10月, 2012 1 次提交
    • F
      AR::AttributeMethods#[] raises AM::AttributeMissingError for missing attributes. · 10f6f90d
      Francesco Rodriguez 提交于
      This fixes the following behaviour:
      
          class Person < ActiveRecord::Base
            belongs_to :company
          end
      
          # Before:
          person = Person.select('id').first
          person[:name]       # => nil
          person.name         # => ActiveModel::MissingAttributeError: missing_attribute: name
          person[:company_id] # => nil
          person.company      # => nil
      
          # After:
          person = Person.select('id').first
          person[:name]       # => ActiveModel::MissingAttributeError: missing_attribute: name
          person.name         # => ActiveModel::MissingAttributeError: missing_attribute: name
          person[:company_id] # => ActiveModel::MissingAttributeError: missing_attribute: company_id
          person.company      # => ActiveModel::MissingAttributeError: missing_attribute: company_id
      
      Fixes #5433.
      10f6f90d
  22. 26 10月, 2012 1 次提交
    • J
      Remove ActiveRecord::Model · 9e4c41c9
      Jon Leighton 提交于
      In the end I think the pain of implementing this seamlessly was not
      worth the gain provided.
      
      The intention was that it would allow plain ruby objects that might not
      live in your main application to be subclassed and have persistence
      mixed in. But I've decided that the benefit of doing that is not worth
      the amount of complexity that the implementation introduced.
      9e4c41c9
  23. 22 10月, 2012 3 次提交