Rails 7 & Active Record - ArgumentError: Unknown key: :source

Viewed 159

I am working on a Rails 7 upgrade from Rails 6 and I constantly get an error regarding the source key on active record relationships.

I have multiple places like: has_many :custom_accounts, through: :services, source: :bank_account

and get the error:

ArgumentError:

Unknown key: :source. Valid keys are: :class_name, :anonymous_class, :primary_key, :foreign_key, :dependent, :validate, :inverse_of, :strict_loading, :autosave, :before_add, :after_add, :before_remove, :after_remove, :extend, :counter_cache, :join_table, :index_errors

I cannot find any documentation or other posts regarding a deprecation of the :source key. And these worked before upgrading Rails to 7.0.3 (and automatically active_record as well)

I also tried changing this into class_name & foreign_key, but that does not work as it suggests adding a source.

0 Answers
Related