1. 29 4月, 2015 1 次提交
  2. 20 4月, 2015 2 次提交
  3. 09 4月, 2015 1 次提交
    • A
      Batch touch parent records · 89713897
      Arthur Neves 提交于
      [fixes #18606]
      
      Make belongs_to use touch over touch_later when running the callbacks.
      
      Add more tests and small method rename
      
      Thanks Jeremy for the feedback.
      89713897
  4. 02 3月, 2015 1 次提交
    • A
      call `sync_with_transaction_state` inside `persisted?` then check ivars · 57d35b2b
      Aaron Patterson 提交于
      directly
      
      calling `sync_with_transaction_state` is not fast, so if we call it
      once, we can improve the performance of the `persisted?` method.  This
      is important because every call to `url_for(model)` will call
      `persisted?`, so we want that to be fast.
      
      Here is the benchmark:
      
      ```ruby
      require 'active_record'
      
      ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
      
      ActiveRecord::Base.connection.instance_eval do
        create_table(:articles)
      end
      
      class Article < ActiveRecord::Base; end
      article = Article.new.tap(&:save!)
      
      Benchmark.ips do |x|
        x.report("persisted?") do
          article.persisted?
        end
      end
      ```
      
      Before this patch:
      
      ```
      $ bundle exec ruby -rbenchmark/ips persisted.rb
      Calculating -------------------------------------
                persisted?     3.333k i/100ms
      -------------------------------------------------
                persisted?     51.037k (± 8.2%) i/s -    253.308k
      ```
      
      After:
      
      ```
      $ bundle exec ruby -rbenchmark/ips persisted.rb
      Calculating -------------------------------------
                persisted?     7.172k i/100ms
      -------------------------------------------------
                persisted?    120.730k (± 5.1%) i/s -    602.448k
      ```
      57d35b2b
  5. 18 2月, 2015 1 次提交
    • H
      Add `time` option to `#touch` · 219d71fb
      Hyonjee Joo 提交于
      Fixes #18905. `#touch` now takes time as an option. Setting the option
      saves the record with the updated_at/on attributes set to the current time
      or the time specified. Updated tests and documentation accordingly.
      219d71fb
  6. 04 2月, 2015 1 次提交
    • M
      Always reset changed attributes in becomes · 5f6370a8
      Miklos Fazekas 提交于
      When ```becomes``` changes @attributes it should also change
      @changed_attributes. Otherwise we'll experience a kind of split head situation
      where attributes are coming from ```self```, but changed_attributes is coming
      from ```klass.new```. This affects the inheritance_colmn as it's changed by new
      for example.
      
      Fixes #16881
      5f6370a8
  7. 02 2月, 2015 1 次提交
  8. 23 1月, 2015 1 次提交
  9. 18 1月, 2015 1 次提交
  10. 15 1月, 2015 1 次提交
  11. 03 1月, 2015 1 次提交
    • C
      Deprecate `false` as the way to halt AR callbacks · bb78af73
      claudiob 提交于
      Before this commit, returning `false` in an ActiveRecord `before_` callback
      such as `before_create` would halt the callback chain.
      
      After this commit, the behavior is deprecated: will still work until
      the next release of Rails but will also display a deprecation warning.
      
      The preferred way to halt a callback chain is to explicitly `throw(:abort)`.
      bb78af73
  12. 30 12月, 2014 1 次提交
    • C
      Add doc for `:touch` option of AR::Base#save · 5e84a24f
      claudiob 提交于
      ActiveRecord::Base `save` and `save!` take an option boolean
      `:touch` parameter since #18225 (stems from #18202).
      
      This commit document that parameter.
      
      [ci skip]
      5e84a24f
  13. 28 12月, 2014 1 次提交
  14. 25 12月, 2014 1 次提交
  15. 04 12月, 2014 1 次提交
  16. 28 11月, 2014 1 次提交
  17. 26 11月, 2014 1 次提交
  18. 18 11月, 2014 1 次提交
  19. 15 11月, 2014 1 次提交
  20. 07 11月, 2014 1 次提交
    • F
      Print out a meaningful error when ActiveRecord::ReadOnlyRecord is raised · d424ded6
      Franky W 提交于
      Currently, there is no messages which get printed out. Convoluted system
      may have hooks that create other objects in which case we only fail with
      no messages. This commit changes this information allowing you to know
      which object is the one that actually raised the error.
      d424ded6
  21. 06 11月, 2014 1 次提交
    • S
      Improve performance of AR object instantiation · 8fee9238
      Sean Griffin 提交于
      We introduced a performance hit by adding an additional iteration
      through a model's attributes on creation. We don't actually need the
      values from `Result` to be a hash, we can separate the columns and
      values and zip them up ourself during the iteration that we have to do.
      8fee9238
  22. 29 9月, 2014 1 次提交
    • B
      Isolate access to @associations_cache and @aggregations cache to the... · 9d569585
      Ben Woosley 提交于
      Isolate access to @associations_cache and @aggregations cache to the Associations and Aggregations modules, respectively.
      
      This includes replacing the `association_cache` accessor with a more
      limited `association_cached?` accessor and making `clear_association_cache`
      and `clear_aggregation_cache` private.
      9d569585
  23. 17 8月, 2014 1 次提交
  24. 11 8月, 2014 1 次提交
  25. 08 8月, 2014 1 次提交
  26. 07 8月, 2014 1 次提交
  27. 05 8月, 2014 1 次提交
  28. 04 7月, 2014 1 次提交
  29. 23 6月, 2014 2 次提交
  30. 20 6月, 2014 1 次提交
  31. 14 6月, 2014 2 次提交
    • S
      Remove unused column types override · ea6f28c8
      Sean Griffin 提交于
      ea6f28c8
    • S
      Introduce an Attribute object to handle the type casting dance · 6f08db05
      Sean Griffin 提交于
      There's a lot more that can be moved to these, but this felt like a good
      place to introduce the object. Plans are:
      
      - Remove all knowledge of type casting from the columns, beyond a
        reference to the cast_type
      - Move type_cast_for_database to these objects
      - Potentially make them mutable, introduce a state machine, and have
        dirty checking handled here as well
      - Move `attribute`, `decorate_attribute`, and anything else that
        modifies types to mess with this object, not the columns hash
      - Introduce a collection object to manage these, reduce allocations, and
        not require serializing the types
      6f08db05
  32. 11 6月, 2014 1 次提交
    • S
      No need to decorate columns twice · da3b4b61
      Sean Griffin 提交于
      We never want result types to override column types, and
      `decorate_columns` can only affect column types. No need to go through
      the decoration multiple times, we can just exclude the column types from
      the result types instead.
      da3b4b61
  33. 07 6月, 2014 1 次提交
  34. 04 6月, 2014 1 次提交
  35. 02 6月, 2014 1 次提交
  36. 31 5月, 2014 1 次提交
    • S
      Rename attribute related instance variables to better express intent · eb6cee9c
      Sean Griffin 提交于
      `@attributes` was actually used for `_before_type_cast` and friends,
      while `@attributes_cache` is the type cast version (and caching is the
      wrong word there, but I'm working on removing the conditionals around
      that). I opted for `@raw_attributes`, because `_before_type_cast` is
      also semantically misleading. The values in said hash are in the state
      given by the form builder or database, so raw seemed to be a good word.
      eb6cee9c
  37. 20 5月, 2014 1 次提交