I have used validates_xxxx_of method in the model. Here is an extract
of the returned object:
0: &id001 !ruby/object:ProductOption
- invalid name
- name missing
- invalid color
- color missing
1: &id003 …
As you can see, there is an index for the object, because I am saving
multiple records in the same time.
I know that I can access to the errors by
error_messages_for/each_full_messages method, however, I am not sure how
to use it in my case.
So, is there a way to access to the errors “invalid name”, “name
missing”, etc. in the model and construct a more meaningful object to
return to the controller?