E
E
eldar_web2017-03-05 16:03:52
JavaScript
eldar_web, 2017-03-05 16:03:52

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

4 answer(s)
S
Shaks, 2017-03-05
@eldar_web

But how can you harmoniously implement all this in accordance with the model?

gem client_side_validations - quite handy, and everything is consistent with the model
tested the work of the above gem on 5 rails, everything works well.

A
alex maslakoff, 2017-03-05
@teke_teke

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.

D
darksladen, 2017-03-05
@darksladen

Advertising

D
Dmitri Sinitsa, 2017-03-05
@unabl4

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 question

Ask a Question

731 491 924 answers to any question