mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #31479 from iamvery/reword-delegate-allow-nil-paragraph
Clarify docs for delegate :allow_nil option
This commit is contained in:
commit
6553c7fef7
1 changed files with 2 additions and 5 deletions
|
@ -115,11 +115,8 @@ class Module
|
|||
# invoice.customer_address # => 'Vimmersvej 13'
|
||||
#
|
||||
# If the target is +nil+ and does not respond to the delegated method a
|
||||
# +Module::DelegationError+ is raised, as with any other value. Sometimes,
|
||||
# however, it makes sense to be robust to that situation and that is the
|
||||
# purpose of the <tt>:allow_nil</tt> option: If the target is not +nil+, or it
|
||||
# is and responds to the method, everything works as usual. But if it is +nil+
|
||||
# and does not respond to the delegated method, +nil+ is returned.
|
||||
# +Module::DelegationError+ is raised. If you wish to instead return +nil+,
|
||||
# use the <tt>:allow_nil</tt> option.
|
||||
#
|
||||
# class User < ActiveRecord::Base
|
||||
# has_one :profile
|
||||
|
|
Loading…
Reference in a new issue