1. 26 2月, 2019 1 次提交
  2. 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
  3. 19 1月, 2019 1 次提交
  4. 05 1月, 2019 1 次提交
  5. 20 12月, 2018 1 次提交
  6. 13 12月, 2018 1 次提交
  7. 21 11月, 2018 1 次提交
  8. 07 9月, 2018 1 次提交
  9. 23 8月, 2018 1 次提交
    • R
      Fix numericality validator to still use value before type cast except Active Record · 47a6d788
      Ryuta Kamizono 提交于
      The purpose of fe9547b6 is to work type casting to value from database.
      
      But that was caused not to use the value before type cast even except
      Active Record.
      
      There we never guarantees that the value before type cast was going to
      the used in this validation, but we should not change the behavior
      unless there is some particular reason.
      
      To restore original behavior, still use the value before type cast if
      `came_from_user?` is undefined (i.e. except Active Record).
      
      Fixes #33651.
      Fixes #33686.
      47a6d788
  10. 12 8月, 2018 1 次提交
  11. 08 7月, 2018 1 次提交
  12. 12 6月, 2018 1 次提交
  13. 14 3月, 2018 1 次提交
  14. 28 2月, 2018 1 次提交
  15. 18 2月, 2018 1 次提交
  16. 31 1月, 2018 1 次提交
  17. 24 1月, 2018 1 次提交
    • S
      Allow attributes with a proc default to be marshalled · 0af36c62
      Sean Griffin 提交于
      We don't implement much custom marshalling logic for these objects, but
      the proc default case needs to be handled separately. Unfortunately
      there's no way to just say "do what you would have done but with this
      value for one ivar", so we have to manually implement `marshal_load` as
      well.
      
      The test case is a little bit funky, but I'd really like an equality
      test in there, and there's no easy way to add one now that this is out
      of AR (since the `attributes` method isn't here)
      
      Fixes #31216
      0af36c62
  18. 19 12月, 2017 1 次提交
    • Y
      Fix validation callbacks on multiple context · 470d0e45
      Yoshiyuki Hirano 提交于
      I found a bug that validation callbacks don't fire on multiple context.
      So I've fixed it.
      
      Example:
      
      ```ruby
      class Dog
        include ActiveModel::Validations
        include ActiveModel::Validations::Callbacks
      
        attr_accessor :history
      
        def initialize
          @history = []
        end
      
        before_validation :set_before_validation_on_a, on: :a
        before_validation :set_before_validation_on_b, on: :b
        after_validation :set_after_validation_on_a, on: :a
        after_validation :set_after_validation_on_b, on: :b
      
        def set_before_validation_on_a; history << "before_validation on a"; end
        def set_before_validation_on_b; history << "before_validation on b"; end
        def set_after_validation_on_a;  history << "after_validation on a" ; end
        def set_after_validation_on_b;  history << "after_validation on b" ; end
      end
      ```
      
      Before:
      
      ```
      d = Dog.new
      d.valid?([:a, :b])
      d.history # []
      ```
      
      After:
      
      ```
      d = Dog.new
      d.valid?([:a, :b])
      d.history # ["before_validation on a", "before_validation on b", "after_validation on a", "after_validation on b"]
      ```
      470d0e45
  19. 18 12月, 2017 1 次提交
    • S
      Return correct date in ActiveModel for time to date conversions · eb73dfc0
      Sayan Chakraborty 提交于
      time.to_date conversion happens considering leap years
      so a conversion of "Day.new({'day(1i)'=>'1', 'day(2i)'=>'1', 'day(3i)'=>'1'})" results in saving the date as Mon, 03 Jan 0001
      which might seem weird on the user level, hence falling back to parsing on string level resolves this data mismatch
      Fixes #28521
      eb73dfc0
  20. 29 11月, 2017 1 次提交
  21. 28 11月, 2017 1 次提交
  22. 06 11月, 2017 1 次提交
  23. 26 10月, 2017 1 次提交
  24. 08 7月, 2017 1 次提交
    • J
      Add ActiveModel::Errors#merge! · 3650ca98
      Jahfer Husain 提交于
      ActiveModel::Errors#merge! allows ActiveModel::Errors to append errors from
      a separate ActiveModel::Errors instance onto their own.
      
      Example:
      
          person = Person.new
          person.errors.add(:name, :blank)
      
          errors = ActiveModel::Errors.new(Person.new)
          errors.add(:name, :invalid)
      
          person.errors.merge!(errors)
          puts person.errors.messages
          # => { name: ["can't be blank", "is invalid"] }
      3650ca98
  25. 28 6月, 2017 1 次提交
  26. 27 5月, 2017 1 次提交
  27. 30 4月, 2017 1 次提交
  28. 29 3月, 2017 1 次提交
  29. 28 3月, 2017 1 次提交
    • B
      Fix ActiveModel::Errors #keys, #values · 01269aed
      bogdanvlviv 提交于
      Before:
        person.errors.keys    # => []
        person.errors.values  # => []
        person.errors[:name]  # => []
        person.errors.keys    # => [:name]
        person.errors.values  # => [[]]
      
      After:
        person.errors.keys   # => []
        person.errors.values # => []
        person.errors[:name] # => []
        person.errors.keys   # => []
        person.errors.values # => []
      
      Related to #23468
      01269aed
  30. 22 3月, 2017 1 次提交
  31. 04 3月, 2017 1 次提交
  32. 24 2月, 2017 1 次提交
  33. 18 2月, 2017 1 次提交
  34. 07 2月, 2017 2 次提交
  35. 22 11月, 2016 1 次提交
  36. 15 10月, 2016 1 次提交
  37. 12 10月, 2016 2 次提交
    • U
      Remove method for regenerating a token, and update `#authenticate`. · 9b63bf1d
      Unathi Chonco 提交于
      This change now creates a method `#authenticate_XXX` where XXX is
      the configured attribute name on `#has_secure_password`. `#authenticate`
      is now an alias to this method when the attribute name is the default
      'password'
      9b63bf1d
    • U
      This addition will now allow configuring an attribute name for the · 86a48b4d
      Unathi Chonco 提交于
      existing `#has_secure_password`. This can be useful when one would
      like to store some secure field as a digest, just like a password.
      
      The method still defaults to `password`. It now also allows using the
      same `#authenticate` method which now accepts a second argument for
      specifying the attribute to be authenticated, or will default to 'password`.
      
      A new method is also added for generating a new token for an attribute by
      calling `#regenerate_XXXX` where `XXXX` is the attribute name.
      86a48b4d
  38. 11 10月, 2016 1 次提交