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:
parent
6923a532f5
commit
fcd008f06f
1 changed files with 2 additions and 2 deletions
|
@ -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,
|
# You create a new record that uses delegated typing by creating the delegator and delegatee at the same time,
|
||||||
# like so:
|
# 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
|
# 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:
|
# method or class to take care of the complicated needs. This could be as simple as:
|
||||||
#
|
#
|
||||||
# class Entry < ApplicationRecord
|
# class Entry < ApplicationRecord
|
||||||
# def self.create_with_comment(content, creator: Current.user)
|
# 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
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in a new issue