Answer the question
In order to leave comments, you need to log in
rails. relation has_many. How to update correctly?
Hello gurus inhabitants. There are 2 models
personal -> has_many: personal_pictures
picture -> belongs_to: personal
When uploading one photo, I do this:
@personal = Personal.new(personals_params)
@personal.personal_pictures.build(picture: params[:pictures]['picture'], personal_id: personal.id)
@personal.save
@personal = Personal.find(params[:id])
@personal.personal_pictures.update(picture: params[:pictures]['picture'], personal_id: @personal.id)
@personal.update(personals_params)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question