diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index f73f83e..eec9002 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1754,10 +1754,15 @@ module ActiveRecord create_reflection(:has_one, association_id, options, self) end + mattr_accessor :valid_keys_for_has_one_through_association + @@valid_keys_for_has_one_through_association = [ + :class_name, :foreign_key, :remote, :select, :conditions, :order, + :include, :dependent, :counter_cache, :extend, :as, :through, + :source, :source_type, :validate + ] + def create_has_one_through_reflection(association_id, options) - options.assert_valid_keys( - :class_name, :foreign_key, :remote, :select, :conditions, :order, :include, :dependent, :counter_cache, :extend, :as, :through, :source, :source_type, :validate - ) + options.assert_valid_keys(valid_keys_for_has_one_through_association) create_reflection(:has_one, association_id, options, self) end diff --git a/activerecord/lib/active_record/autosave_association.rb b/activerecord/lib/active_record/autosave_association.rb index 8cbae70..b15ddfc 100644 --- a/activerecord/lib/active_record/autosave_association.rb +++ b/activerecord/lib/active_record/autosave_association.rb @@ -116,7 +116,7 @@ module ActiveRecord module AutosaveAssociation extend ActiveSupport::Concern - ASSOCIATION_TYPES = %w{ has_one belongs_to has_many has_and_belongs_to_many } + ASSOCIATION_TYPES = %w{ has_one has_one_through belongs_to has_many has_and_belongs_to_many } included do ASSOCIATION_TYPES.each do |type|