diff options
author | eileencodes <eileencodes@gmail.com> | 2014-06-05 15:27:07 -0400 |
---|---|---|
committer | eileencodes <eileencodes@gmail.com> | 2014-06-09 19:12:43 -0400 |
commit | 5a0b184c53bf649930b153f3c39c542eca25d74a (patch) | |
tree | de847eed7b12932fa4434ef5e835bed82d8ae80a /activerecord/lib/active_record/autosave_association.rb | |
parent | 3fe33a318f29c03966ca5892413884414421108c (diff) | |
download | rails-5a0b184c53bf649930b153f3c39c542eca25d74a.tar.gz rails-5a0b184c53bf649930b153f3c39c542eca25d74a.tar.bz2 rails-5a0b184c53bf649930b153f3c39c542eca25d74a.zip |
add has_one? method and reuse instead of checking macro
Instead of checking for `macro == :has_one` throughout the
codebase we can create a `has_one?` method to match the `belongs_to?`,
`polymorphic?` and other methods.
Diffstat (limited to 'activerecord/lib/active_record/autosave_association.rb')
-rw-r--r-- | activerecord/lib/active_record/autosave_association.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/autosave_association.rb b/activerecord/lib/active_record/autosave_association.rb index 74e2a8e6b9..b3c3e26c9f 100644 --- a/activerecord/lib/active_record/autosave_association.rb +++ b/activerecord/lib/active_record/autosave_association.rb @@ -187,7 +187,7 @@ module ActiveRecord # Doesn't use after_save as that would save associations added in after_create/after_update twice after_create save_method after_update save_method - elsif reflection.macro == :has_one + elsif reflection.has_one? define_method(save_method) { save_has_one_association(reflection) } unless method_defined?(save_method) # Configures two callbacks instead of a single after_save so that # the model may rely on their execution order relative to its |