1. 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
  2. 27 3月, 2013 1 次提交
  3. 22 3月, 2013 1 次提交
  4. 19 3月, 2013 1 次提交
  5. 10 11月, 2012 1 次提交
  6. 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
  7. 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
  8. 22 10月, 2012 3 次提交
  9. 21 10月, 2012 1 次提交
  10. 29 9月, 2012 1 次提交
    • J
      Support for partial inserts. · 144e8691
      Jon Leighton 提交于
      When inserting new records, only the fields which have been changed
      from the defaults will actually be included in the INSERT statement.
      The other fields will be populated by the database.
      
      This is more efficient, and also means that it will be safe to
      remove database columns without getting subsequent errors in running
      app processes (so long as the code in those processes doesn't
      contain any references to the removed column).
      144e8691
  11. 03 8月, 2012 1 次提交
  12. 16 6月, 2012 1 次提交
  13. 09 6月, 2012 2 次提交
  14. 28 3月, 2012 1 次提交
  15. 07 3月, 2012 2 次提交
  16. 06 3月, 2012 1 次提交
  17. 12 2月, 2012 1 次提交
  18. 07 2月, 2012 1 次提交
  19. 21 1月, 2012 1 次提交
  20. 14 1月, 2012 1 次提交
  21. 11 1月, 2012 1 次提交
  22. 29 12月, 2011 1 次提交
  23. 24 12月, 2011 4 次提交
  24. 22 12月, 2011 1 次提交
  25. 16 12月, 2011 2 次提交
  26. 14 12月, 2011 1 次提交
  27. 02 12月, 2011 2 次提交
  28. 28 11月, 2011 1 次提交
  29. 16 11月, 2011 1 次提交
    • J
      association methods are now generated in modules · 7cba6a37
      Josh Susser 提交于
      Instead of generating association methods directly in the model
      class, they are generated in an anonymous module which
      is then included in the model class. There is one such module
      for each association. The only subtlety is that the
      generated_attributes_methods module (from ActiveModel) must
      be forced to be included before association methods are created
      so that attribute methods will not shadow association methods.
      7cba6a37
  30. 14 9月, 2011 1 次提交
    • J
      Stop trying to be clever about when to define attribute methods. · 3b8a7cf2
      Jon Leighton 提交于
      There is no meaningful performance penalty in defining attribute
      methods, since it only happens once.
      
      There is also no reason *not* to define them, since they get thrown in
      an included module, so they will not 'overwrite' anything. In fact, this
      is desirable, since it allows us to call super.
      3b8a7cf2