Answer the question
In order to leave comments, you need to log in
How to solve a problem with a method in multi-model forms?
There is a house controller in which standard methods are specified. I added a custom apartment method to the controller.
The house and apartment models have a has_one and belongs_to relationship, respectively.
In the view, I make a nested form.
= form_for @house do |f|
= f.fields_for :apartment do |ff|
...
def apartment
@house.build_apartment
end
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