Answer the question
In order to leave comments, you need to log in
How to pull out the names of dependent models with errors?
There is a complex order form that belongs to the Client and the Address. Accordingly in the controller:
def new
@order = Order.new
@order.build_kls_client
@order.build_kls_address
end
o.errors.messages.keys.collect(&:to_s).select { |v| v.split('.')[1] }.map { |x| x.split('.')[0]}.uniq
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