aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/form_helpers.md
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2015-12-17 12:16:07 +0100
committerDavid Heinemeier Hansson <david@loudthinking.com>2015-12-17 12:16:07 +0100
commit1bfce3f29d958a14ca1502d3d36a9a2bc1de3734 (patch)
treec170df3f5d2886a669ad757af931a8bb515b0202 /guides/source/form_helpers.md
parent48f5cecdb03f697a710169ccef1885fcaca70788 (diff)
parent4f813a85d8919a83dd6fc019614f6aea7af7d5ae (diff)
downloadrails-1bfce3f29d958a14ca1502d3d36a9a2bc1de3734.tar.gz
rails-1bfce3f29d958a14ca1502d3d36a9a2bc1de3734.tar.bz2
rails-1bfce3f29d958a14ca1502d3d36a9a2bc1de3734.zip
Merge pull request #22626 from gsamokovarov/appliation-record-documentation-fixes
Appliation record documentation fixes
Diffstat (limited to 'guides/source/form_helpers.md')
-rw-r--r--guides/source/form_helpers.md8
1 files changed, 4 insertions, 4 deletions
diff --git a/guides/source/form_helpers.md b/guides/source/form_helpers.md
index 93bb51557a..2a289dd33a 100644
--- a/guides/source/form_helpers.md
+++ b/guides/source/form_helpers.md
@@ -880,12 +880,12 @@ Many apps grow beyond simple forms editing a single object. For example, when cr
Active Record provides model level support via the `accepts_nested_attributes_for` method:
```ruby
-class Person < ActiveRecord::Base
+class Person < ApplicationRecord
has_many :addresses
accepts_nested_attributes_for :addresses
end
-class Address < ActiveRecord::Base
+class Address < ApplicationRecord
belongs_to :person
end
```
@@ -973,7 +973,7 @@ private
You can allow users to delete associated objects by passing `allow_destroy: true` to `accepts_nested_attributes_for`
```ruby
-class Person < ActiveRecord::Base
+class Person < ApplicationRecord
has_many :addresses
accepts_nested_attributes_for :addresses, allow_destroy: true
end
@@ -1014,7 +1014,7 @@ end
It is often useful to ignore sets of fields that the user has not filled in. You can control this by passing a `:reject_if` proc to `accepts_nested_attributes_for`. This proc will be called with each hash of attributes submitted by the form. If the proc returns `false` then Active Record will not build an associated object for that hash. The example below only tries to build an address if the `kind` attribute is set.
```ruby
-class Person < ActiveRecord::Base
+class Person < ApplicationRecord
has_many :addresses
accepts_nested_attributes_for :addresses, reject_if: lambda {|attributes| attributes['kind'].blank?}
end