aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/builder/has_many.rb
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #19686 from tsun1215/index_errorsSean Griffin2015-10-261-1/+1
|\ | | | | | | | | | | Errors can be indexed with nested attributes Close #8638
| * Errors can be indexed with nested attributesMichael Probber2015-04-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `has_many` can now take `index_errors: true` as an option. When this is enabled, errors for nested models will be returned alongside an index, as opposed to just the nested model name. This option can also be enabled (or disabled) globally through `ActiveRecord::Base.index_nested_attribute_errors` E.X. ```ruby class Guitar < ActiveRecord::Base has_many :tuning_pegs accepts_nested_attributes_for :tuning_pegs end class TuningPeg < ActiveRecord::Base belongs_to :guitar validates_numericality_of :pitch end ``` - Old style - `guitar.errors["tuning_pegs.pitch"] = ["is not a number"]` - New style (if defined globally, or set in has_many_relationship) - `guitar.errors["tuning_pegs[1].pitch"] = ["is not a number"]` [Michael Probber, Terence Sun]
* | docs, add missing `:nodoc: for `Associations::Builder`. [ci skip]Yves Senn2015-10-131-1/+1
|/ | | | | | This class is only used internally. We should keep it out of public documentation. This patch adds nodoc for `ActiveRecord::Associations::Builder` and everything nested within.
* Remove support to activerecord-deprecated_findersRafael Mendonça França2015-01-021-2/+2
|
* Add foreign_type option for polymorphic has_one and has_many.Ulisses Almeida + Kassio Borges2014-12-081-1/+1
| | | | | | | To be possible to use a custom column name to save/read the polymorphic associated type in a has_many or has_one polymorphic association, now users can use the option :foreign_type to inform in what column the associated object type will be saved.
* Fix custom join_table name on habtm reflectionsKassio Borges2014-04-251-1/+1
| | | | | | When used a custom join_table name on a habtm, rails was not saving it on Reflections. This causes a problem when rails loads fixtures, because it uses the reflections to set database with fixtures.
* Revert the whole refactoring in the association builder classes.Rafael Mendonça França2013-12-111-2/+2
| | | | This is to get activerecord-deprecated_finders work again
* Bring back the valid_options class accessorRafael Mendonça França2013-12-111-1/+1
| | | | It is need in activerecord-deprecated_finders
* Move macro to class levelRafael Mendonça França2013-10-091-1/+1
|
* Make valid_options a class methodRafael Mendonça França2013-10-091-1/+1
|
* valid_options doesn't depend on the instance, so push it to the classAaron Patterson2013-10-021-1/+1
|
* Dropped deprecated option `:restrict` for `:dependent` in associationsNeeraj Singh2013-07-031-1/+1
|
* Getting rid of the +automatic_inverse_of: false+ option in associations in favorwangjohn2013-06-081-1/+1
| | | | | of using +inverse_of: false+ option. Changing the documentation and adding a CHANGELOG entry for the automatic inverse detection feature.
* Created a method to automatically find inverse associations and cachewangjohn2013-05-071-1/+1
| | | | | | the results. Added tests to check to make sure that inverse associations are automatically found when has_many, has_one, or belongs_to associations are defined.
* :counter_cache option for to support custom named counter caches. Closes #7993Yves Senn2012-11-041-1/+1
|
* DRY up handling of dependent optionJon Leighton2012-08-101-22/+2
|
* Unprivatise all the thingsJon Leighton2012-08-101-14/+12
| | | | | | Well, not all of them, but some of them. I don't think there's much reason for these methods to be private.
* move dependency logic out of generated methodsJon Leighton2012-08-101-25/+4
|
* Clean up dependent option validation.Jon Leighton2012-08-101-3/+1
| | | | | 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-101-2/+2
| | | | | | | | | | | | | | | 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.
* load active_support/core_ext/object/inclusion in active_support/railsXavier Noria2012-08-021-1/+0
|
* Refactor dependency check validationCarlos Antonio da Silva2012-08-011-6/+4
| | | | | | 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-011-4/+3
|
* stop using class_attribute where methods/inheritance will suffice.Jon Leighton2012-07-131-2/+6
|
* no longer need #delete_all_on_destroyJon Leighton2012-05-181-1/+1
|
* Same method for has_many and has_one associationsPaco Guzman2012-01-311-14/+0
|
* Easy dependent_restrict error messagePaco Guzman2012-01-311-2/+1
|
* has_many/has_one, :dependent => :restrict, deprecation added.Manoj2012-01-291-1/+10
|
* Removed metaclass from the has_many dependency destroy method. Fixes #2954Dmitry Polushkin2011-12-311-6/+1
|
* Fix #3672 again (dependent: delete_all perf)Jon Leighton2011-12-141-1/+7
|
* avoid warningsJosh Susser2011-11-271-3/+3
| | | | | | | This change uses Module.redefine_method as defined in ActiveSupport. Making Module.define_method public would be as clean in the code, and would also emit warnings when redefining an association. That is pretty messy given current tests, so I'm leaving it for someone else to decide what approach is better.
* association methods are now generated in modulesJosh Susser2011-11-151-3/+3
| | | | | | | | | | Instead of generating association methods directly in the model class, they are generated in an anonymous module which is then included in the model class. There is one such module for each association. The only subtlety is that the generated_attributes_methods module (from ActiveModel) must be forced to be included before association methods are created so that attribute methods will not shadow association methods.
* 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/+3
| | | | 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?.
* Use proper objects to do the work to build the associations (adding methods, ↵Jon Leighton2011-02-211-0/+63
callbacks etc) rather than calling a whole bunch of methods with rather long names.