I’m still getting the same error even tho I used different names for the schema fields.
schema "users" do
has_many :accounts, Account
has_one :selected_account, Account, foreign_key: :selected_user_account_id
end
schema "accounts" do
belongs_to :user, User
belongs_to :user, User, foreign_key: :selected_user_account_id
end
The error is:
field/association :user already exists on schema, you must either remove the duplication or choose a different name
Updated
I still have the error after adding an explicit foreign_key
.
schema "users" do
has_many :accounts, Account, foreign_key: :all_user_accounts_id
has_one :selected_account, Account, foreign_key: :selected_user_account_id
end
schema "accounts" do
belongs_to :user, User, foreign_key: :all_user_accounts_id
belongs_to :user, User, foreign_key: :selected_user_account_id
end