1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

[skip-ci] Fix delegated_type examples

This commit is contained in:
Niklas Häusele 2020-05-24 15:20:37 +02:00 committed by GitHub
parent 6923a532f5
commit fcd008f06f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -101,14 +101,14 @@ module ActiveRecord
# You create a new record that uses delegated typing by creating the delegator and delegatee at the same time,
# like so:
#
# Entry.create! message: Comment.new(content: "Hello!"), creator: Current.user
# Entry.create! entryable: Comment.new(content: "Hello!"), creator: Current.user
#
# If you need more complicated composition, or you need to perform dependent validation, you should build a factory
# method or class to take care of the complicated needs. This could be as simple as:
#
# class Entry < ApplicationRecord
# def self.create_with_comment(content, creator: Current.user)
# create! message: Comment.new(content: content), creator: creator
# create! entryable: Comment.new(content: content), creator: creator
# end
# end
#