aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/reflection.rb
Commit message (Collapse)AuthorAgeFilesLines
* Refactor to use each_key, remove extra spacesCarlos Antonio da Silva2013-01-281-1/+0
|
* Added STI support to init and building associationsJason Rush2012-11-291-1/+1
| | | | | | | | 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.
* Another batch of hash syntax changes to comment, this time around, I tried ↵AvnerCohen2012-10-231-12/+12
| | | | to keep 'output' messages untouched.
* Remove mass_assignment_options from ActiveRecordGuillermo Iguaran2012-09-161-2/+2
|
* Refactor to remove some duplicationJon Leighton2012-09-121-0/+4
|
* load active_support/core_ext/class/attribute in active_support/railsXavier Noria2012-08-021-1/+0
|
* load active_support/core_ext/object/inclusion in active_support/railsXavier Noria2012-08-021-1/+0
|
* Revert "Removing composed_of from ActiveRecord."Rafael Mendonça França2012-07-271-5/+40
| | | | | | | | | | | This reverts commit 14fc8b34521f8354a17e50cd11fa3f809e423592. Reason: we need to discuss a better path from this removal. Conflicts: activerecord/lib/active_record/reflection.rb activerecord/test/cases/base_test.rb activerecord/test/models/developer.rb
* remove unused methodJon Leighton2012-07-201-4/+0
|
* Represent association scope options as AR::Relations insternally.Jon Leighton2012-07-131-19/+15
|
* Allow associations to take a lambda which builds the scopeJon Leighton2012-07-131-4/+7
|
* Improve the derivation of HABTM assocation join table namesAndrew White2012-06-221-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Improve the derivation of HABTM join table name to take account of nesting. It now takes the table names of the two models, sorts them lexically and then joins them, stripping any common prefix from the second table name. Some examples: Top level models (Category <=> Product) Old: categories_products New: categories_products Top level models with a global table_name_prefix (Category <=> Product) Old: site_categories_products New: site_categories_products Nested models in a module without a table_name_prefix method (Admin::Category <=> Admin::Product) Old: categories_products New: categories_products Nested models in a module with a table_name_prefix method (Admin::Category <=> Admin::Product) Old: categories_products New: admin_categories_products Nested models in a parent model (Catalog::Category <=> Catalog::Product) Old: categories_products New: catalog_categories_products Nested models in different parent models (Catalog::Category <=> Content::Page) Old: categories_pages New: catalog_categories_content_pages Also as part of this commit the validity checks for HABTM assocations have been moved to ActiveRecord::Reflection One side effect of this is to move when the exceptions are raised from the point of declaration to when the association is built. This is consistant with other association validity checks.
* Removing composed_of from ActiveRecord.Steve Klabnik2012-06-181-40/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This feature adds a lot of complication to ActiveRecord for dubious value. Let's talk about what it does currently: class Customer < ActiveRecord::Base composed_of :balance, :class_name => "Money", :mapping => %w(balance amount) end Instead, you can do something like this: def balance @balance ||= Money.new(value, currency) end def balance=(balance) self[:value] = balance.value self[:currency] = balance.currency @balance = balance end Since that's fairly easy code to write, and doesn't need anything extra from the framework, if you use composed_of today, you'll have to add accessors/mutators like that. Closes #1436 Closes #2084 Closes #3807
* Simplify AR configuration code.Jon Leighton2012-06-151-2/+1
| | | | | Get rid of ActiveModel::Configuration, make better use of ActiveSupport::Concern + class_attribute, etc.
* de-globalise methodJon Leighton2012-05-041-0/+4
|
* Refactor and cleanup in some ActiveRecord modulesCarlos Antonio da Silva2012-03-031-9/+9
| | | | | | | | | | | * Avoid double hash lookups in AR::Reflection when reflecting associations/aggregations * Minor cleanups: use elsif, do..end, if..else instead of unless..else * Simplify DynamicMatchers#respond_to? * Use "where" instead of scoped with conditions hash * Extract `scoped_by` method pattern regexp to constant * Extract noisy class_eval from method_missing in dynamic matchers * Extract readonly check, avoid calling column#to_s twice in persistence * Refactor predicate builder, remove some variables
* Remove useless argument in #columns.Sebastian Martinez2012-02-021-2/+2
|
* no need for extra method calls inside the frameworkAaron Patterson2012-01-091-1/+1
|
* Support configuration on ActiveRecord::Model.Jon Leighton2011-12-281-1/+2
| | | | | | | | | | | | | | | The problem: We need to be able to specify configuration in a way that can be inherited to models that include ActiveRecord::Model. So it is no longer sufficient to put 'top level' config on ActiveRecord::Base, but we do want configuration specified on ActiveRecord::Base and descendants to continue to work. So we need something like class_attribute that can be defined on a module but that is inherited when ActiveRecord::Model is included. The solution: added ActiveModel::Configuration module which provides a config_attribute macro. It's a bit specific hence I am not putting this in Active Support or making it a 'public API' at present.
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2011-12-161-1/+1
|\
| * Update activerecord/lib/active_record/reflection.rbAlexander2011-12-141-1/+1
| |
* | Don't try to autosave nested assocs. Fixes #2961.Jon Leighton2011-12-141-0/+4
|/
* Allow the :class_name option for associations to take a symbol.Jon Leighton2011-11-041-1/+1
| | | | | This is to avoid confusing newbies, and to be consistent with the fact that other options like :foreign_key already allow a symbol or a string.
* Fix #3271.Jon Leighton2011-11-031-1/+1
| | | | | | | | Building the conditions of a nested through association could potentially modify the conditions of the through and/or source association. This is a Bad Thing.
* Raise an exception on unknown primary key inside AssociationReflection.Jon Leighton2011-10-051-4/+8
| | | | | An association between two models cannot be made if a relevant key is unknown, so fail fast rather than generating invalid SQL. Fixes #3207.
* Don't call self.class unless necessary. Closes #3171.Jon Leighton2011-09-291-2/+2
|
* Fix belongs_to polymorphic with custom primary key on target.Jon Leighton2011-09-261-15/+11
| | | | Closes #3104.
* Ensure we are not comparing a string with a symbol in ↵Jon Leighton2011-09-061-1/+1
| | | | HasManyAssociation#inverse_updates_counter_cache?. Fixes #2755, where a counter cache could be decremented twice as far as it was supposed to be.
* calling super is super. if the other object is exactly equal, we can return ↵Aaron Patterson2011-07-011-1/+5
| | | | early
* Remove AssociationReflection#create_association and ↵Jon Leighton2011-06-301-17/+0
| | | | AssociationReflection#create_association! - they are not called from anywhere.
* Assign the association attributes to the associated record before the ↵Jon Leighton2011-06-301-2/+2
| | | | before_initialize callback of the record runs. Fixes #1842.
* cache the plural name on the reflection so we do not pay pluralize costs on ↵Aaron Patterson2011-06-301-6/+13
| | | | joins
* Merge branch 'master' of github.com:rails/railsXavier Noria2011-05-251-6/+0
|\
| * removed deprecated methods, and related tests, from ActiveRecordJosh Kalderimis2011-05-251-6/+0
| |
* | Merge branch 'master' of git://github.com/lifo/docrailsXavier Noria2011-05-251-1/+1
|\ \ | |/ |/| | | | | | | Conflicts: actionmailer/lib/action_mailer/base.rb activesupport/lib/active_support/core_ext/kernel/requires.rb
| * Remove extra white spaces on ActiveRecord docs.Sebastian Martinez2011-05-231-1/+1
| |
* | Fix problem with loading polymorphic associations which have been defined in ↵Jon Leighton2011-05-221-5/+4
|/ | | | an abstract superclass. Fixes #552.
* Remove `#among?` from Active SupportPrem Sichanugrist2011-04-131-1/+1
| | | | | | After a long list of discussion about the performance problem from using varargs and the reason that we can't find a great pair for it, it would be best to remove support for it for now. It will come back if we can find a good pair for it. For now, Bon Voyage, `#among?`.
* Change Object#either? to Object#among? -- thanks to @jamesarosen for the ↵David Heinemeier Hansson2011-04-121-1/+1
| | | | suggestion!
* Using Object#in? and Object#either? in various placesPrem Sichanugrist2011-04-111-1/+2
| | | | There're a lot of places in Rails source code which make a lot of sense to switching to Object#in? or Object#either? instead of using [].include?.
* Simplify implementation of ThroughReflection#chainJon Leighton2011-03-111-22/+2
|
* Rename Reflection#through_reflection_chain and #through_options to ↵Jon Leighton2011-03-101-27/+33
| | | | Reflection#chain and Reflection#options as they now no longer relate solely to through associations.
* Move the code which builds a scope for through associations into a generic ↵Jon Leighton2011-03-101-3/+3
| | | | AssociationScope class which is capable of building a scope for any association.
* Fix ↵Jon Leighton2011-03-071-1/+1
| | | | test_has_many_association_through_a_has_many_association_with_nonstandard_primary_keys
* Refactor ThroughAssociation#join_to to be much smaller, and independent of ↵Jon Leighton2011-03-061-0/+6
| | | | construct_owner_conditions.
* Push source_type and polymorphic conditions out of ThroughAssociation and ↵Jon Leighton2011-03-051-10/+11
| | | | JoinDependency::JoinAssociation and into the reflection instead.
* Add a test for STI on the through where the through is nested, and change ↵Jon Leighton2011-03-051-0/+3
| | | | the code which support this
* Merge branch 'master' into nested_has_many_throughJon Leighton2011-03-041-18/+65
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: activerecord/CHANGELOG activerecord/lib/active_record/association_preload.rb activerecord/lib/active_record/associations.rb activerecord/lib/active_record/associations/class_methods/join_dependency.rb activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb activerecord/lib/active_record/associations/has_many_association.rb activerecord/lib/active_record/associations/has_many_through_association.rb activerecord/lib/active_record/associations/has_one_association.rb activerecord/lib/active_record/associations/has_one_through_association.rb activerecord/lib/active_record/associations/through_association_scope.rb activerecord/lib/active_record/reflection.rb activerecord/test/cases/associations/has_many_through_associations_test.rb activerecord/test/cases/associations/has_one_through_associations_test.rb activerecord/test/cases/reflection_test.rb activerecord/test/cases/relations_test.rb activerecord/test/fixtures/memberships.yml activerecord/test/models/categorization.rb activerecord/test/models/category.rb activerecord/test/models/member.rb activerecord/test/models/reference.rb activerecord/test/models/tagging.rb
| * Rewrote AssociationPreload.Jon Leighton2011-02-281-4/+6
| |
| * Delegate Association#options to the reflection, and replace ↵Jon Leighton2011-02-211-0/+8
| | | | | | | | 'reflection.options' with 'options'. Also add through_options and source_options methods for through associations.