1. 26 4月, 2017 1 次提交
    • R
      Remove useless test case · 111ae374
      Ryuta Kamizono 提交于
      Cannot call private methods in `@klass` against `CollectionProxy`
      (inherites `Relation`) because using `public_send` in `method_missing`.
      111ae374
  2. 05 1月, 2017 1 次提交
  3. 29 10月, 2016 1 次提交
  4. 07 8月, 2016 3 次提交
  5. 27 10月, 2015 2 次提交
  6. 22 10月, 2015 1 次提交
    • R
      Refactor Calculations#execute_grouped_calculation and clean AR test case · 4f21d42f
      Rafael Sales 提交于
      * When tried to use `Company#accounts` test/models/company.rb I got:
      
      ```
      ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column:
      accounts.company_id: SELECT COUNT(*) AS count_all, "companies"."firm_id"
      AS companies_firm_id FROM "companies" INNER JOIN "accounts" ON
      "accounts"."company_id" = "companies"."id" GROUP BY "companies"."firm_id"
      ```
      
      * The refactor on Calculations class was just to simplify the code
      4f21d42f
  7. 27 9月, 2015 1 次提交
    • E
      Fix regression in inverse_of on through associations · ee824c88
      eileencodes 提交于
      `inverse_of` on through associations was accidently removed/caused to
      stop working in commit f8d2899d which was part of a refactoring on
      `ThroughReflection`.
      
      To fix we moved `inverse_of` and `check_validity_of_inverse!` to the
      `AbstractReflection` so it's available to the `ThroughReflection`
      without having to dup any methods. We then need to delegate `inverse_name`
      method in `ThroughReflection`. `inverse_name` can't be moved to
      `AbstractReflection` without moving methods that set the instance
      variable `@automatic_inverse_of`.
      
      This adds a test that ensures that `inverse_of` on a `ThroughReflection`
      returns the correct class name, and the correct record for the inverse
      relationship.
      
      Fixes #21692
      ee824c88
  8. 11 5月, 2015 1 次提交
    • A
      allow setting of a demodulized class name when using STI · cbd66b43
      Alex Robbin 提交于
      If your STI class looks like this:
      
      ```ruby
      class Company < ActiveRecord::Base
        self.store_full_sti_class = false
      
        class GoodCo < Company
        end
      
        class BadCo < Company
        end
      end
      ```
      
      The expectation (which is valid) is that the `type` in the database is saved as
      `GoodCo` or `BadCo`. However, another expectation should be that setting `type`
      to `GoodCo` would correctly instantiate the object as a `Company::GoodCo`. That
      second expectation is what this should fix.
      cbd66b43
  9. 19 2月, 2015 1 次提交
  10. 31 12月, 2014 1 次提交
    • R
      Fix error message when trying to create an associated record · 04852b87
      Rafael Mendonça França 提交于
      This error only happens when the foreign key is missing.
      
      Before this fix the following exception was being raised:
      
          NoMethodError: undefined method `val' for #<Arel::Nodes::BindParam:0x007fc64d19c218>
      
      Now the message is:
      
          ActiveRecord::UnknownAttributeError: unknown attribute 'foreign_key' for Model.
      04852b87
  11. 28 8月, 2014 1 次提交
  12. 15 11月, 2013 1 次提交
  13. 04 10月, 2013 1 次提交
  14. 26 9月, 2013 1 次提交
  15. 11 9月, 2013 1 次提交
  16. 18 8月, 2013 1 次提交
  17. 25 7月, 2013 1 次提交
  18. 03 7月, 2013 2 次提交
  19. 02 7月, 2013 1 次提交
  20. 14 6月, 2013 1 次提交
    • A
      Ambiguous reflections are on :through relationships are no longer supported. · b483a0d2
      Aaron Patterson 提交于
      For example, you need to change this:
      
        class Author < ActiveRecord::Base
          has_many :posts
          has_many :taggings, :through => :posts
        end
      
        class Post < ActiveRecord::Base
          has_one :tagging
          has_many :taggings
        end
      
        class Tagging < ActiveRecord::Base
        end
      
      To this:
      
        class Author < ActiveRecord::Base
          has_many :posts
          has_many :taggings, :through => :posts, :source => :tagging
        end
      
        class Post < ActiveRecord::Base
          has_one :tagging
          has_many :taggings
        end
      
        class Tagging < ActiveRecord::Base
        end
      b483a0d2
  21. 02 5月, 2013 1 次提交
    • G
      Handle aliased attributes in ActiveRecord::Relation. · 54122067
      Godfrey Chan 提交于
      When using symbol keys, ActiveRecord will now translate aliased attribute names to the actual column name used in the database:
      
      With the model
      
        class Topic
          alias_attribute :heading, :title
        end
      
      The call
      
        Topic.where(heading: 'The First Topic')
      
      should yield the same result as
      
        Topic.where(title: 'The First Topic')
      
      This also applies to ActiveRecord::Relation::Calculations calls such as `Model.sum(:aliased)` and `Model.pluck(:aliased)`.
      
      This will not work with SQL fragment strings like `Model.sum('DISTINCT aliased')`.
      
      Github #7839
      
      *Godfrey Chan*
      54122067
  22. 29 11月, 2012 1 次提交
    • J
      Added STI support to init and building associations · 89b5b31c
      Jason Rush 提交于
      Allows you to do BaseClass.new(:type => "SubClass") as well as
      parent.children.build(:type => "SubClass") or parent.build_child
      to initialize an STI subclass. Ensures that the class name is a
      valid class and that it is in the ancestors of the super class
      that the association is expecting.
      89b5b31c
  23. 17 9月, 2012 1 次提交
  24. 04 9月, 2012 1 次提交
  25. 11 8月, 2012 1 次提交
    • J
      Remove the dependent_restrict_raises option. · 5ad79989
      Jon Leighton 提交于
      It's not really a good idea to have this as a global config option. We
      should allow people to specify the behaviour per association.
      
      There will now be two new values:
      
      * :dependent => :restrict_with_exception implements the current
        behaviour of :restrict. :restrict itself is deprecated in favour of
        :restrict_with_exception.
      * :dependent => :restrict_with_error implements the new behaviour - it
        adds an error to the owner if there are dependent records present
      
      See #4727 for the original discussion of this.
      5ad79989
  26. 02 8月, 2012 2 次提交
  27. 21 7月, 2012 1 次提交
  28. 20 7月, 2012 1 次提交
  29. 03 5月, 2012 1 次提交
  30. 01 2月, 2012 1 次提交
  31. 31 1月, 2012 1 次提交
  32. 17 1月, 2012 1 次提交
  33. 30 11月, 2011 1 次提交
  34. 04 11月, 2011 1 次提交
  35. 13 6月, 2011 1 次提交