I have three models in my Rails applicaiton. As described below, user can have more phones and phone can belong to more customers.
class Customer < ActiveRecord::Base
has_many :customer_phone_associations, dependent: :destroy
has_many :phones, through: :customer_phone_associations
end
class Phone < ActiveRecord::Base
has_many :customer_phone_associations
has_many :customers, through: :customer_phone_associations
end
class CustomerPhoneAssociation < ActiveRecord::Base
belongs_to :customer
belongs_to :phone
end
In customer's form, I need text input when user can insert more phones, separated by commas. When the form is submitted, data should insert into three database tables: customer's data to Customer table, phone's to Phone table and association between customer and phone to extra table. How could I create such a form?