Skip to content

Commit c419435

Browse files
committed
Fix delegated type example
Must specify `account` parameter because of the association defined in `Entry`.
1 parent 0f9aaa5 commit c419435

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

activerecord/lib/active_record/delegated_type.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ module ActiveRecord
102102
# You create a new record that uses delegated typing by creating the delegator and delegatee at the same time,
103103
# like so:
104104
#
105-
# Entry.create! entryable: Comment.new(content: "Hello!"), creator: Current.user
105+
# Entry.create! entryable: Comment.new(content: "Hello!"), creator: Current.user, account: Current.account
106106
#
107107
# If you need more complicated composition, or you need to perform dependent validation, you should build a factory
108108
# method or class to take care of the complicated needs. This could be as simple as:
109109
#
110110
# class Entry < ApplicationRecord
111-
# def self.create_with_comment(content, creator: Current.user)
112-
# create! entryable: Comment.new(content: content), creator: creator
111+
# def self.create_with_comment(content, creator: Current.user, account: Current.account)
112+
# create! entryable: Comment.new(content: content), creator: creator, account: account
113113
# end
114114
# end
115115
#

0 commit comments

Comments
 (0)