aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations
Commit message (Collapse)AuthorAgeFilesLines
...
* | move dependency logic out of generated methodsJon Leighton2012-08-107-65/+64
| |
* | Clean up dependent option validation.Jon Leighton2012-08-104-14/+7
| | | | | | | | | | We don't need the complexity of to_sentence, and it shouldn't be a bang method.
* | Remove the dependent_restrict_raises option.Jon Leighton2012-08-103-23/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Fix #7191. Remove unnecessary transaction when assigning has_one associations.kennyj2012-08-081-13/+15
| |
* | removes usage of Object#in? from the code base (the method remains defined ↵Xavier Noria2012-08-062-10/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | by Active Support) Selecting which key extensions to include in active_support/rails made apparent the systematic usage of Object#in? in the code base. After some discussion in https://github.com/rails/rails/commit/5ea6b0df9a36d033f21b52049426257a4637028d we decided to remove it and use plain Ruby, which seems enough for this particular idiom. In this commit the refactor has been made case by case. Sometimes include? is the natural alternative, others a simple || is the way you actually spell the condition in your head, others a case statement seems more appropriate. I have chosen the one I liked the most in each case.
* | Changing AR:CollectionAssociation#empty? to use #exists?beerlington2012-08-051-3/+11
| | | | | | | | | | COUNT(*) queries can be slow in PostgreSQL, #exists? avoids this by selecting a single record.
* | load active_support/deprecation in active_support/railsXavier Noria2012-08-022-2/+0
| |
* | load active_support/core_ext/object/inclusion in active_support/railsXavier Noria2012-08-025-5/+0
| |
* | load active_support/core_ext/object/blank in active_support/railsXavier Noria2012-08-021-1/+0
| |
* | s/scoped/scope/Jon Leighton2012-08-017-25/+31
| |
* | Add CollectionProxy#scopeJon Leighton2012-08-011-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This can be used to get a Relation from an association. Previously we had a #scoped method, but we're deprecating that for AR::Base, so it doesn't make sense to have it here. This was requested by DHH, to facilitate code like this: Project.scope.order('created_at DESC').page(current_page).tagged_with(@tag).limit(5).scoping do @topics = @project.topics.scope @todolists = @project.todolists.scope @attachments = @project.attachments.scope @documents = @project.documents.scope end
* | Use explicit delegationsJon Leighton2012-08-011-119/+79
| | | | | | | | | | | | | | This makes it easier to see what the documentation refers to. It also means that we are not doing unnecessary work for delegations that have no args / splats / block / etc.
* | Deprecate :finder_sql, :counter_sql, :insert_sql, :delete_sql.Jon Leighton2012-08-013-1/+22
| |
* | Revert "Remove :finder_sql, :counter_sql, :insert_sql, :delete_sql."Jon Leighton2012-08-017-35/+111
| | | | | | | | | | | | | | | | | | This reverts commit 3803fcce26b837c0117f7d278b83c366dc4ed370. Conflicts: activerecord/CHANGELOG.md It will be deprecated only in 4.0, and removed properly in 4.1.
* | Refactor dependency check validationCarlos Antonio da Silva2012-08-014-28/+19
| | | | | | | | | | | | Move the logic for validation check to the same method, and cache dependent option in a variable to reuse inside the dependency configuration methods instead of relying on the options hash.
* | move method for dependent option checkHrvoje Šimić2012-08-014-11/+22
| |
* | fix typo in collection proxyAccessd2012-07-311-1/+1
| |
* | Deprecate Relation#all.Jon Leighton2012-07-271-1/+1
| | | | | | | | | | | | It has been moved to active_record_deprecated_finders. Use #to_a instead.
* | Deprecate ActiveRecord::Base.scoped.Jon Leighton2012-07-273-7/+3
| | | | | | | | | | | | | | It doesn't serve much purpose now that ActiveRecord::Base.all returns a Relation. The code is moved to active_record_deprecated_finders.
* | Deprecate update_column in favor of update_columns.Rafael Mendonça França2012-07-241-1/+1
| | | | | | | | Closes #1190
* | we don't need this argJon Leighton2012-07-201-2/+2
| |
* | Remove :finder_sql, :counter_sql, :insert_sql, :delete_sql.Jon Leighton2012-07-207-111/+35
| |
* | Remove obsolete line.Jon Leighton2012-07-201-1/+0
| | | | | | | | | | | | | | | | This code is broken (it should say association_scope.uniq_value rather than options[:uniq]) but the tests still pass. I think it is designed to uniq-ify associations using finder_sql. However, I am about to remove that anyway.
* | Convert association macros to the new syntaxJon Leighton2012-07-201-1/+1
| |
* | Avoid options ever being nilJon Leighton2012-07-201-4/+4
| | | | | | | | This fixes active_record_deprecated_finders.
* | fix association :extend optionJon Leighton2012-07-133-12/+19
| |
* | move the deprecated options into active_record_deprecated_findersJon Leighton2012-07-132-5/+2
| |
* | stop using class_attribute where methods/inheritance will suffice.Jon Leighton2012-07-137-29/+53
| |
* | extract deprecated association options to active_record_deprecated_findersJon Leighton2012-07-131-43/+0
| |
* | Represent association scope options as AR::Relations insternally.Jon Leighton2012-07-1312-127/+138
| |
* | Allow associations to take a lambda which builds the scopeJon Leighton2012-07-133-13/+22
| |
* | Improve the derivation of HABTM assocation join table namesAndrew White2012-06-224-33/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Set the hash value directly instead of using merge!Carlos Antonio da Silva2012-06-211-1/+1
| |
* | Remove unneeded code since pluck is respecting joins nowRafael Mendonça França2012-06-191-12/+1
| |
* | Remove update_attribute.Steve Klabnik2012-06-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | Historically, update_attribute and update_attributes are similar, but with one big difference: update_attribute does not run validations. These two methods are really easy to confuse given their similar names. Therefore, update_attribute is being removed in favor of update_column. See the thread on rails-core here: https://groups.google.com/forum/?fromgroups#!topic/rubyonrails-core/BWPUTK7WvYA
* | Merge branch 'master-sec'Aaron Patterson2012-05-311-2/+17
|\ \ | | | | | | | | | | | | | | | * master-sec: Strip [nil] from parameters hash. Thanks to Ben Murphy for reporting this! predicate builder should not recurse for determining where columns. Thanks to Ben Murphy for reporting this
| * | predicate builder should not recurse for determining where columns.Aaron Patterson2012-05-301-2/+17
| | | | | | | | | | | | | | | | | | Thanks to Ben Murphy for reporting this CVE-2012-2661
* | | Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-05-301-1/+1
|\ \ \
| * | | change example on CollectionProxy#delete to accept multiple valuesFrancesco Rodriguez2012-05-281-1/+1
| | | |
* | | | Add support for CollectionAssociation#delete by Fixnum or StringFrancesco Rodriguez2012-05-282-0/+27
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I found the next issue between CollectionAssociation `delete` and `destroy`. class Person < ActiveRecord::Base has_many :pets end person.pets.destroy(1) # => OK, returns the destroyed object person.pets.destroy("2") # => OK, returns the destroyed object person.pets.delete(1) # => ActiveRecord::AssociationTypeMismatch person.pets.delete("2") # => ActiveRecord::AssociationTypeMismatch Adding support for deleting with a fixnum or string like `destroy` method.
* | | add CollectionProxy#uniq documentationFrancesco Rodriguez2012-05-261-0/+21
| | |
* | | add :nodoc: to CollectionProxy#initializeFrancesco Rodriguez2012-05-251-1/+1
| | |
* | | add CollectionProxy#== documentationFrancesco Rodriguez2012-05-251-0/+24
| | |
* | | add CollectionProxy#count documentationFrancesco Rodriguez2012-05-251-0/+26
| | |
* | | add CollectionProxy#to_ary documentationFrancesco Rodriguez2012-05-251-2/+35
| | |
* | | add CollectionProxy#delete documentationFrancesco Rodriguez2012-05-251-1/+104
| | |
* | | copy edits in collection proxy docs [ci skip]Vijay Dev2012-05-231-25/+18
| | |
* | | Revert "Remove blank trailing comments"Vijay Dev2012-05-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit fa6d921e11363e9b8c4bc10f7aed0b9faffdc33a. Reason: Not a fan of such massive changes. We usually close such changes if made to Rails master as a pull request. Following the same principle here and reverting. [ci skip]
* | | add CollectionProxy#length documentationFrancesco Rodriguez2012-05-221-5/+37
| | |
* | | add CollectionProxy#size documentationFrancesco Rodriguez2012-05-221-2/+25
| | |