aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/nested_attributes.rb
Commit message (Collapse)AuthorAgeFilesLines
* Extra caller details added to ActiveRecord::RecordNotFoundSameer Rahmani2015-07-211-1/+3
| | | | | | | | | | | | | | | | ActiveRecord::RecordNotFound modified to store model name, primary_key and id of the caller model. It allows the catcher of this exception to make a better decision to what to do with it. For example consider this simple example: class SomeAbstractController < ActionController::Base rescue_from ActiveRecord::RecordNotFound, with: :redirect_to_404 private def redirect_to_404(e) return redirect_to(posts_url) if e.model == 'Post' raise end end
* Ensure that 'ActionController::Parameters' can still be passed to AR for ↵Thomas Walpole2015-07-181-0/+6
| | | | collection associations
* Ensure that `ActionController::Parameters` can still be passed to ARSean Griffin2015-07-181-0/+3
| | | | | | | | | | | | | | | | | | | | | Since nested hashes are also instances of `ActionController::Parameters`, and we're explicitly looking to work with a hash for nested attributes, this caused breakage in several points. This is the minimum viable fix for the issue (and one that I'm not terribly fond of). I can't think of a better place to handle this at the moment. I'd prefer to use some sort of solution that doesn't special case AC::Parameters, but we can't use something like `to_h` or `to_a` since `Enumerable` adds both. While I've added a trivial test case for verifying this fix in isolation, we really need better integration coverage to prevent regressions like this in the future. We don't actually have a lot of great places for integration coverage at the moment, so I'm deferring it for now. Fixes #20922.
* "maybe" => "may be"Waynn Lue2015-05-211-1/+1
|
* docs for updating nested attributes while creating parent record [cish6khan2015-05-181-0/+5
| | | | skip]
* fixed typoBenny Klotz2015-04-281-2/+2
|
* `type_cast_from_user` -> `cast`Sean Griffin2015-02-171-1/+1
|
* Always perform validations on nested attribute associationsSean Griffin2015-01-301-0/+1
| | | | | | | Collection associations would have already been validated, but singular associations were not. Fixes #18735.
* Don't redefine autosave association callbacks in nested attrsSean Griffin2015-01-281-1/+0
| | | | | | | | These callbacks will already have been defined when the association was built. The check against `reflection.autosave` happens at call time, not at define time, so simply modifying the reflection is sufficient. Fixes #18704
* A quick pass through NestedAttributes' doc [ci skip]Robin Dupret2015-01-021-18/+20
|
* Add information about "allow_destroy" requiring an ID. [ci skip]George Millo2014-12-231-0/+3
| | | | | | | I just wasted an absurd amount of time trying to figure out why my model wasn't being deleted even though I was setting `_destroy` to true like the instructions said. Making the documentation a little bit clear so that someone like me doesn't waste their time in future.
* Rename `type_cast` to `type_cast_from_database`Sean Griffin2014-06-091-1/+1
| | | | | | | | In some cases there is a difference between the two, we should always be doing one or the other. For convenience, `type_cast` is still a private method on type, so new types that do not need different behavior don't need to implement two methods, but it has been moved to private so it cannot be used accidentally.
* Move types to the top level `ActiveRecord` namespaceSean Griffin2014-05-271-1/+1
| | | | | `ActiveRecord::ConnectionAdapters::Type::Value` => `ActiveRecord::Type::Value`
* Refactoring .reflections public method.Arthur Neves2014-05-261-1/+0
| | | | | | Now the internal reflections will hold a reference to its public representation, so when the outside world calls `Account.reflection` we can build a list of public reflections.
* Merge pull request #15210 from arthurnn/fix_hbtm_reflectionArthur Neves2014-05-241-2/+3
| | | | | | | | | Fix habtm reflection Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/counter_cache.rb activerecord/lib/active_record/reflection.rb activerecord/test/cases/reflection_test.rb
* Inline typecasting helpers from Column to the appropriate typesSean Griffin2014-05-201-1/+1
|
* [ci skip] Improve doc, fix grammatical issueAkshay Vishnoi2014-04-131-4/+4
|
* Renamed generated_feature_methods to generated_association_methods.kennyj2013-09-281-1/+1
|
* Restore the use of `#add_to_target` for nested attribute updates on existing ↵Ben Woosley2013-08-121-11/+10
| | | | | | | | | records, and don't bother updating the association if the update is going to be rejected anyway. This requires adding a `skip_callbacks` argument to `#add_to_target` so that we don't call the callbacks multiple times in this case, which is functionally an application of existing association data, rather than an addition of a new record to the association.
* Fix interactions between :before_add callbacks and nested attributes assignmentDr.(USA) Joerg Schray2013-08-121-10/+9
| | | | | Issue #1: :before_add callback is called when nested attributes assignment assigns to existing record if the association is not yet loaded Issue #2: Nested Attributes assignment does not affect the record in the association target when callback triggers loading of the association
* let the object stay in charge of internal cache invalidationAaron Patterson2013-06-131-6/+1
|
* Getting rid of the +automatic_inverse_of: false+ option in associations in favorwangjohn2013-06-081-0/+4
| | | | | 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-0/+5
| | | | | | 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.
* Do not overwrite manually built records during one-to-one nested attribute ↵Olek Janiszewski2013-05-031-7/+32
| | | | | | | | | | | | | | | | | | | | | assignment For one-to-one nested associations, if you build the new (in-memory) child object yourself before assignment, then the NestedAttributes module will not overwrite it, e.g.: class Member < ActiveRecord::Base has_one :avatar accepts_nested_attributes_for :avatar def avatar super || build_avatar(width: 200) end end member = Member.new member.avatar_attributes = {icon: 'sad'} member.avatar.width # => 200
* Added a bang to the end of +raise_nested_attributes_record_not_found+wangjohn2013-04-061-3/+3
| | | | method to signify an exception possibly being raised.
* Fix my typoAlexey Muranov2013-03-121-1/+1
|
* Align indentation in commentsAlexey Muranov2013-03-121-15/+15
|
* Document nested attributes as hash of hashesAlexey Muranov2013-03-121-2/+26
| | | Document the possibility to use a hash of hashes for nested attributes for a one-to-many association (in addition to the documented possibility to use an array of hashes).
* Refactored nested associations so they are more readable. Added commentswangjohn2013-03-081-26/+54
| | | | which make it clearer about what's going on.
* Change docs to use update instead of update_attributesAmparo Luna + Guillermo Iguaran2013-01-031-1/+1
|
* 1.9 Syntax related changesAvnerCohen2012-11-101-35/+35
|
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-11-031-3/+3
|\ | | | | | | | | | | | | Conflicts: actionpack/lib/action_controller/metal/mime_responds.rb activerecord/lib/active_record/attribute_methods.rb guides/source/working_with_javascript_in_rails.md
| * Fixed typo on ActiveRecord nested_attributes.Luis M2012-10-231-3/+3
| |
* | Remove ActiveRecord::ModelJon Leighton2012-10-261-6/+2
| | | | | | | | | | | | | | | | | | | | In the end I think the pain of implementing this seamlessly was not worth the gain provided. The intention was that it would allow plain ruby objects that might not live in your main application to be subclassed and have persistence mixed in. But I've decided that the benefit of doing that is not worth the amount of complexity that the implementation introduced.
* | Revert "Get rid of the ActiveRecord::Model::DeprecationProxy thing."Jeremy Kemper2012-10-201-1/+1
| | | | | | | | This reverts commit 83846838252397b3781eed165ca301e05db39293.
* | Get rid of the ActiveRecord::Model::DeprecationProxy thing.Jon Leighton2012-10-191-1/+1
|/ | | | | | | | | | | | | | | | | I think it's going to be too much pain to try to transition the :active_record load hook from executing against Base to executing against Model. For example, after Model is included in Base, and modules included in Model will no longer get added to the ancestors of Base. So plugins which wish to be compatible with both Model and Base should use the :active_record_model load hook which executes *before* Base gets loaded. In general, ActiveRecord::Model is an advanced feature at the moment and probably most people will continue to inherit from ActiveRecord::Base for the time being.
* Remove unused private method AR::NestedAttributes#unassignable_keys and ↵Guillermo Iguaran2012-09-191-5/+1
| | | | reference to mass_assignment options
* Remove mass_assignment_options from ActiveRecordGuillermo Iguaran2012-09-161-12/+10
|
* Remove mass assignment security from ActiveRecordGuillermo Iguaran2012-09-161-15/+1
|
* Refactor nested attributes limit logic to lookup :limit option only onceCarlos Antonio da Silva2012-09-081-11/+12
|
* allow to pass Symbol or Proc into :limit option of ↵Mikhail Dieterle2012-08-261-3/+13
| | | | #accepts_nested_attributes_for
* load active_support/core_ext/class/attribute in active_support/railsXavier Noria2012-08-021-1/+0
|
* load active_support/core_ext/object/blank in active_support/railsXavier Noria2012-08-021-1/+0
|
* s/scoped/scope/Jon Leighton2012-08-011-1/+1
|
* Made ArgumentError messages consistent.Philip Arndt2012-07-061-2/+2
|
* Simplify AR configuration code.Jon Leighton2012-06-151-1/+5
| | | | | Get rid of ActiveModel::Configuration, make better use of ActiveSupport::Concern + class_attribute, etc.
* better wordingHrvoje Šimić2012-05-111-4/+4
|
* Nested attribute setters can be overridden.Jonathan Mukai & Peter Jaros2012-03-281-1/+1
| | | | Overriding implementation can call super.
* Modified comments explaining what the update_only option does.Mark2012-02-281-8/+19
|
* Array.wrap is an overhead as there is already check for classSergey Nartimov2012-01-061-1/+1
|