1. 05 7月, 2014 1 次提交
    • S
      Add a `required` option to singular associations · 00f55516
      Sean Griffin 提交于
      In addition to defining the association, a `required` association will
      also have its presence validated.
      
      Before:
      
      ```ruby
      belongs_to :account
      validates_presence_of :account
      ```
      
      After:
      
      ```ruby
      belongs_to :account, required: true
      ```
      
      This helps to draw a distinction between types of validations, since
      validations on associations are generally for data integrity purposes,
      and aren't usually set through form inputs.
      00f55516
  2. 26 6月, 2014 1 次提交
    • S
      Deprecate automatic counter caches on has_many :through · d730e374
      Sean Griffin 提交于
      Reliant on https://github.com/rails/rails/pull/15747 but pulled to a
      separate PR to reduce noise. `has_many :through` associations have the
      undocumented behavior of automatically detecting counter caches.
      However, the way in which it does so is inconsistent with counter caches
      everywhere else, and doesn't actually work consistently.
      
      As with normal `has_many` associations, the user should specify the
      counter cache on the `belongs_to`, if they'd like it updated.
      d730e374
  3. 25 6月, 2014 1 次提交
  4. 23 6月, 2014 1 次提交
  5. 22 6月, 2014 1 次提交
  6. 20 6月, 2014 1 次提交
  7. 18 6月, 2014 2 次提交
  8. 16 6月, 2014 1 次提交
    • S
      Always update counter caches in memory when adding records · e6690d37
      Sean Griffin 提交于
      Before, calling `size` would only work if it skipped the cache, and
      would return a different result from the cache, but only if:
      
      - The association was previously loaded
      - Or you called size previously
      - But only if the size was 0 when you called it
      
      This ensures that the counter is appropriately updated in memory.
      e6690d37
  9. 14 6月, 2014 2 次提交
  10. 11 6月, 2014 1 次提交
    • E
      begin refactoring add_constraints by moving join keys · 5823e429
      eileencodes 提交于
      add_constraints is complicated and difficult to read. This is the
      beginning of a long process of refactoring this code. First step:
      moved the join keys out of AssociationScope and into reflection.
      
      We then don't need to call `reflection` because now reflection is
      `self`.
      
      `foreign_key` must be named something else because reflection already has a
      `foreign_key` method and when passed into `JoinKeys` it was getting the
      wrong assignment. `reflection_foreign_key` seemed to be an appropriate name.
      I also named `key` `reflection_key` to match `reflection_foreign_key`.
      5823e429
  11. 10 6月, 2014 4 次提交
  12. 09 6月, 2014 1 次提交
  13. 04 6月, 2014 3 次提交
  14. 03 6月, 2014 1 次提交
    • E
      fix polymorphic? method and reuse it · 46acd8b8
      eileencodes 提交于
      Fix polymorphic to check for `options[:polymorphic]` instead of
      `options.key? :polymorphic` and then reuse the method `polymorphic?`
      method instead of constantly checking the same `options[:polymorphic]`.
      46acd8b8
  15. 25 5月, 2014 2 次提交
  16. 21 5月, 2014 3 次提交
  17. 20 5月, 2014 1 次提交
  18. 18 5月, 2014 1 次提交
    • E
      early return on delete and destroy methods · 540262af
      eileencodes 提交于
      When delete or destroy is called on all records nothing
      is deleted or destroyed. Intead of running through the code and still
      not deleteing anything, we should early return
      540262af
  19. 17 5月, 2014 3 次提交
  20. 15 5月, 2014 1 次提交
  21. 14 5月, 2014 4 次提交
    • E
      remove count var · 34db2b7c
      eileencodes 提交于
      this change was unneccsary as nothing was gained from it
      34db2b7c
    • E
      rename delete_all_records to delete_or_nullify_all_records · 05a90c36
      eileencodes 提交于
      Rename delete_all_records because this name better describes
      what the method is doing. We can then remove :all from the
      hm:t version and pull out the unoptimized call to load_target
      in delete_records and pass it directly.
      05a90c36
    • E
      remove need for :all symbol · 1c851b8c
      eileencodes 提交于
      Refactor delete_count method to only handle delete_all or nullify/nil cases
      and not destroy and switch to if/else rather than case statement. This
      refactoring allows removal of :all symbol usage.
      1c851b8c
    • E
      begin refactoring delete_records method · d8ae2764
      eileencodes 提交于
      Refactor by creating two methods delete_all_records and delete_records
      to be called by delete_all and delete (or destroy) respectively.
      This reduces the number of conditionals required to handle _how_
      records get deleted.
      
      The new delete_count method handles how scope is applied to which
      delete action.
      
      A delete_all_records method also has to be called in has_many_through
      association because of how the methods are chained. This will be
      refactored later on.
      d8ae2764
  22. 13 5月, 2014 1 次提交
  23. 10 5月, 2014 1 次提交
  24. 08 5月, 2014 1 次提交
    • F
      Fixed HABTM's CollectionAssociation size · f045663d
      Fred Wu 提交于
      HABTM should fall back to using the normal CollectionAssociation's size calculation if the collection is not cached or loaded.
      
      This addresses both #14913 and #14914 for master.
      f045663d
  25. 07 5月, 2014 1 次提交
    • J
      Follow-up to #14990 [ci skip] · 22f25183
      Jon Atack 提交于
      Rewrite to avoid 'we'/'you', add missing period, and keep lines at 80 chars. Cheers :)
      
      Improve readability with help from @senny
      
      [ci skip]
      22f25183