1. 20 3月, 2020 1 次提交
  2. 19 12月, 2019 1 次提交
  3. 14 12月, 2019 1 次提交
  4. 10 12月, 2019 1 次提交
  5. 27 11月, 2019 1 次提交
  6. 05 11月, 2019 1 次提交
  7. 03 11月, 2019 1 次提交
  8. 01 11月, 2019 1 次提交
  9. 21 10月, 2019 2 次提交
  10. 17 8月, 2019 1 次提交
  11. 23 7月, 2019 1 次提交
  12. 28 5月, 2019 1 次提交
  13. 04 5月, 2019 1 次提交
  14. 25 4月, 2019 1 次提交
  15. 24 4月, 2019 1 次提交
    • R
      Avoid redundant `attribute_alias?` before `attribute_alias` · 5575bd7b
      Ryuta Kamizono 提交于
      If we want to get alias resolved attribute finally, we can use
      `attribute_alias` directly.
      
      For that purpose, avoiding redundant `attribute_alias?` makes alias
      attribute access 40% faster.
      
      https://gist.github.com/kamipo/e427f080a27b46f50bc508fae3612a0e
      
      Before (2c0729d8):
      
      ```
      Warming up --------------------------------------
                user['id']   102.668k i/100ms
            user['new_id']    80.660k i/100ms
              user['name']    99.368k i/100ms
          user['new_name']    81.626k i/100ms
      Calculating -------------------------------------
                user['id']      1.431M (± 4.0%) i/s -      7.187M in   5.031985s
            user['new_id']      1.042M (± 4.2%) i/s -      5.243M in   5.039858s
              user['name']      1.406M (± 5.6%) i/s -      7.055M in   5.036743s
          user['new_name']      1.074M (± 3.6%) i/s -      5.387M in   5.024152s
      ```
      
      After (this change):
      
      ```
      Warming up --------------------------------------
                user['id']   109.775k i/100ms
            user['new_id']   103.303k i/100ms
              user['name']   105.988k i/100ms
          user['new_name']    99.618k i/100ms
      Calculating -------------------------------------
                user['id']      1.520M (± 6.7%) i/s -      7.574M in   5.011496s
            user['new_id']      1.485M (± 6.2%) i/s -      7.438M in   5.036252s
              user['name']      1.538M (± 5.4%) i/s -      7.737M in   5.049765s
          user['new_name']      1.516M (± 4.6%) i/s -      7.571M in   5.007293s
      ```
      5575bd7b
  16. 23 4月, 2019 2 次提交
  17. 13 4月, 2019 2 次提交
    • C
      Improve wording of comments · c9d75177
      Chris Salzberg 提交于
      Most of the time, these methods are called from actual methods defined
      from columns in the schema, not from method_missing, so the current
      wording is misleading.
      c9d75177
    • C
      Rename method_missing_target to target · bdcdb2b3
      Chris Salzberg 提交于
      The target of matchers is used in two contexts: to define attribute
      methods which dispatch to handlers like attribute_was, and to match
      method calls in method_missing and dispatch to those same handler
      methods.
      
      Only in the latter context does the term "method_missing_target" make
      any sense; in the former context it is just confusing. "target" is not
      ideal as a term but at least it avoids this confusion.
      bdcdb2b3
  18. 12 4月, 2019 2 次提交
  19. 11 4月, 2019 1 次提交
    • R
      PERF: 2x ~ 30x faster dirty tracking · 6b0a9de9
      Ryuta Kamizono 提交于
      Currently, although using both dirty tracking (ivar backed and
      attributes backed) on one model is not supported (doesn't fully work at
      least), both dirty tracking are being performed, that is very slow.
      
      As long as attributes backed dirty tracking is used, ivar backed dirty
      tracking should not need to be performed.
      
      I've refactored to extract new `ForcedMutationTracker` which only tracks
      `force_change` to be performed for ivar backed dirty tracking, that
      makes dirty tracking on Active Record 2x ~ 30x faster.
      
      https://gist.github.com/kamipo/971dfe0891f0fe1ec7db8ab31f016435
      
      Before:
      
      ```
      Warming up --------------------------------------
                  changed?     4.467k i/100ms
                   changed     5.134k i/100ms
                   changes     3.023k i/100ms
        changed_attributes     4.358k i/100ms
              title_change     3.185k i/100ms
                 title_was     3.381k i/100ms
      Calculating -------------------------------------
                  changed?     42.197k (±28.5%) i/s -    187.614k in   5.050446s
                   changed     50.481k (±16.0%) i/s -    246.432k in   5.045759s
                   changes     30.799k (± 7.2%) i/s -    154.173k in   5.030765s
        changed_attributes     51.530k (±14.2%) i/s -    252.764k in   5.041106s
              title_change     44.667k (± 9.0%) i/s -    222.950k in   5.040646s
                 title_was     44.635k (±16.6%) i/s -    216.384k in   5.051098s
      ```
      
      After:
      
      ```
      Warming up --------------------------------------
                  changed?    24.130k i/100ms
                   changed    13.503k i/100ms
                   changes     6.511k i/100ms
        changed_attributes     9.226k i/100ms
              title_change    48.221k i/100ms
                 title_was    96.060k i/100ms
      Calculating -------------------------------------
                  changed?    245.478k (±16.1%) i/s -      1.182M in   5.015837s
                   changed    157.641k (± 4.9%) i/s -    796.677k in   5.066734s
                   changes     70.633k (± 5.7%) i/s -    358.105k in   5.086553s
        changed_attributes     95.155k (±13.6%) i/s -    470.526k in   5.082841s
              title_change    566.481k (± 3.5%) i/s -      2.845M in   5.028852s
                 title_was      1.487M (± 3.9%) i/s -      7.493M in   5.046774s
      ```
      6b0a9de9
  20. 05 4月, 2019 1 次提交
  21. 30 3月, 2019 2 次提交
    • R
      Type cast falsy boolean symbols on boolean attribute as false · 2d12f800
      Ryuta Kamizono 提交于
      Before 34cc301f, type casting by boolean attribute when querying is a
      no-op, so finding by truthy boolean string (i.e.
      `where(value: "true") # => value = 'true'`) didn't work as expected
      (matches it to FALSE in MySQL #32624). By type casting is ensured, a
      value on boolean attribute is always serialized to TRUE or FALSE.
      
      In PostgreSQL, `where(value: :false) # => value = 'false'` was a valid
      SQL, so 34cc301f is a regresson for PostgreSQL since all symbol values
      are serialized as TRUE.
      
      I'd say using `:false` is mostly a developer's mistake (user's input
      basically comes as a string), but `:false` on boolean attribute is
      serialized as TRUE is not a desirable behavior for anybody.
      
      This allows falsy boolean symbols as false, i.e.
      `klass.create(value: :false).value? # => false` and
      `where(value: :false) # => value = FALSE`.
      
      Fixes #35676.
      2d12f800
    • P
      Rename `i18n_full_message` config option to `i18n_customize_full_message` · d8ba2f7c
      Prathamesh Sonpatki 提交于
      - I feel `i18n_customize_full_messages` explains the meaning of the
        config better.
      - Followup of https://github.com/rails/rails/pull/32956
      d8ba2f7c
  22. 22 3月, 2019 1 次提交
    • S
      Reintroduce support for overriding `has_secure_password` attributes · 4733e04d
      Seb Jacobs 提交于
      In Rails 5.2.x calling `has_secure_password` would define attribute
      readers and writers on the superclass of the model, which meant that you
      could override these attributes in a model and call the superclass for
      example:
      
      ```
      class Dog < ApplicationRecord
        has_secure_password
      
        def password=(new_password)
          @password_set = new_password.present?
          super
        end
      end
      ```
      
      However this behaviour was broken in Rails 6 when the ability to
      customise the name of the attribute was introduced [1] since they are no
      longer being defined on the superclass you will now see the following
      error:
      
      ```
      NoMethodError:
      super: no superclass method `password=' for #<Dog:0x00007ffbbc7ce290>
      Did you mean?  password
      ```
      
      In order to resolve this issue and retain support for setting a custom
      attribute name we can define these attribute readers/writers in a module
      and then ensure that the module is included in the inheritance chain.
      
      [1] https://www.github.com/rails/rails/commit/86a48b4da3
          https://www.github.com/rails/rails/commit/9b63bf1dfd
      4733e04d
  23. 11 3月, 2019 1 次提交
    • E
      Prep release · 7c87fd56
      eileencodes 提交于
      * Update RAILS_VERSION
      * Bundle
      * rake update_versions
      * rake changelog:header
      7c87fd56
  24. 05 3月, 2019 1 次提交
  25. 26 2月, 2019 1 次提交
  26. 21 2月, 2019 1 次提交
  27. 20 2月, 2019 1 次提交
    • R
      Don't allow `where` with non numeric string matches to 0 values · 357cd23d
      Ryuta Kamizono 提交于
      This is a follow-up of #35310.
      
      Currently `Topic.find_by(id: "not-a-number")` matches to a `id = 0`
      record. That is considered as silently leaking information.
      
      If non numeric string is given to find by an integer column, it should
      not be matched to any record.
      
      Related #12793.
      357cd23d
  28. 18 2月, 2019 3 次提交
  29. 31 1月, 2019 1 次提交
  30. 26 1月, 2019 1 次提交
  31. 23 1月, 2019 1 次提交
    • E
      Fix NumericalityValidator on object responding to `to_f`: · f01e3850
      Edouard CHIN 提交于
      - If you had a PORO that acted like a Numeric, the validator would
        work correctly because it was previously using `Kernel.Float`
        which is implicitely calling `to_f` on the passed argument.
      
        Since rails/rails@d126c0d , we are now using `BigDecimal` which does
        not implicitely call `to_f` on the argument, making the validator
        fail with an underlying `TypeError` exception.
      
        This patch replate the `is_decimal?` check with `Kernel.Float`.
        Using `Kernel.Float` as argument for the BigDecimal call has two
        advantages:
      
        1. It calls `to_f` implicetely for us.
        2. It's also smart enough to detect that `Kernel.Float("a")` isn't a
           Numeric and will raise an error.
           We don't need the `is_decimal?` check thanks to that.
      
        Passing `Float::DIG` as second argument to `BigDecimal` is mandatory
        because the precision can't be omitted when passing a Float.
        `Float::DIG` is what is used internally by ruby when calling
        `123.to_d`
      
        https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/lib/bigdecimal/util.rb#L47
      
      - Another small issue introduced in https://github.com/rails/rails/pull/34693
        would now raise a TypeError because `Regexp#===` will just return
        false if the passed argument isn't a string or symbol, whereas
        `Regexp#match?` will.
      f01e3850
  32. 21 1月, 2019 1 次提交
    • A
      Fix year value when casting a multiparameter time hash · ccdedeb9
      Andrew White 提交于
      When assigning a hash to a time attribute that's missing a year
      component (e.g. a `time_select` with `:ignore_date` set to `true`)
      then the year defaults to 1970 instead of the expected 2000. This
      results in the attribute changing as a result of the save.
      
      Before:
      
          event = Event.new(start_time: { 4 => 20, 5 => 30 })
          event.start_time # => 1970-01-01 20:30:00 UTC
          event.save
          event.reload
          event.start_time # => 2000-01-01 20:30:00 UTC
      
      After:
      
          event = Event.new(start_time: { 4 => 20, 5 => 30 })
          event.start_time # => 2000-01-01 20:30:00 UTC
          event.save
          event.reload
          event.start_time # => 2000-01-01 20:30:00 UTC
      ccdedeb9
  33. 19 1月, 2019 1 次提交