Answer the question
In order to leave comments, you need to log in
How do you do form validation via AJAX in a modern way in Ruby on Rails?
Form validation is perhaps a complex process for developers.
You can do ajax validation manually.
But how can you harmoniously implement all this in accordance with the model?
Yes, there are on the Internet, but they seem to be old and not very good.
Answer the question
In order to leave comments, you need to log in
But how can you harmoniously implement all this in accordance with the model?
I think that there is nothing complicated. just do it like you do with a post request: take parameters, create a model, check valid? if not, then an array of errors is returned with field names in json. if it's valid, then keep it.
What is so special about AJAX? From the point of view of the data validation process, it does not affect anything, i.e. validation occurs in exactly the same way.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question