I have two entities Project
and Domain
.
How can I code this:
domain has_many :project
project belongs_to :domain # so I have a domain_id column in `project`.
Because I have a form_for
on the project index, it is a bit different saving the domain_id
(project table) and save data into domain
table.
I don’t need the code
I just need some pointers, I already have a working solution, but the models associations are opposite to what I wrote above, and I have nested forms, and to get the domain value I have to do this.
def domain_params
params.require(: project).permit!(:name, :domain_id, :domain).tap do |whitelisted|
whitelisted[:domain] = params[:project][:domain]
end