'has_many relation on the same source

The User references both the Software Model and it's DAW scope in this example, both relating to the Software model

Whenever i use the below code - every time a user updates their data from the View page it writes the association to the Software table instead of the User table.

 Software Update (1.5ms)  UPDATE "softwares" SET "user_id" = $1, "updated_at" = $2 WHERE "softwares"."id" = $3  [["user_id", 76338], ["updated_at", "2022-03-07 11:54:08.903184"], ["id", 8]]

I require each user to store the daw ID of their preference - but at the minute it's writing the User ID of the user saving into the Software table which overwrites the data.

Software Model

has_and_belongs_to_many :users    
scope :daws, -> {where is_daw:true}

User Model

has_and_belongs_to_many :softwares
has_many :daws, -> {Software.daws}, :class_name => 'Software'

View

<%= f.association :daws, label: false, :input_html => { :multiple => false } %>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source