-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
validates_uniqueness_of-validation show up just before redirect after create #13
Comments
Hmm..actually becuase of how I made remote validations fail fast but succeed slow to make it impossible to submit the form while AJAX request is being performed...this is a tricky one. |
It's a bit tricky to get client-side + remote to work side-a-side (sync vs async), but a matter of time spent on it I guess. Been focusing on getting the client-side ones as Rails-alike and thorough as possible. Will revisit this soon, not highest priority. |
Would making the "fast failure" state a "fast loading" state instead be easier? In the meantime is it possible to make an additional configuration setting: ::ValidatiousOnRails.remote_validations_by_default = false |
validates_uniqueness_of the client-side way is not pragmatic, that's why there's not even possible to do that now. Filling a page with loads of record data...I dunno, also there are plenty of options for uniqueness - such as scopes - that is not possible to implement even if filling the view with record values would be "okay". I got on my todo to implement possibility to do the client-side validation either client-side or with AJAX, but not the other way around for validators that are remote by defaults. Too much complexity that may not be obvious. |
Haha, sorry for the confusion. I meant to create a configuration setting to turn of all AJAX validations, not convert them to client-side... THAT would be ridiculous. That was before I realized I could just do: validates_uniqueness_of :name, :client_side => false Sorry to bother, I've been up all night and I need to stop bug-reporting without any sleep. |
=) There is a global setting for this, but documentation is not the best right now: This file in generated with the generator automatically. |
Sorry, I wanted to use a global setting to turn off remote validations, while leaving client-side validations on. In other words, disable validate_uniqueness_of validations using Validatious. I ended up just modifying the initial value of an AJAX validation to true: It removed the flicker I was getting, while still letting the remote validations fail when incorrect. Thanks for all your help and keep up the good work! When I learn more ruby and rails I'll be sure to contribute where I can. |
I see. Cool, thanks! Same situation as me like a year ago. ;) |
FYI; My only solution on this one is probably a constant timer polling ajax validation every 500 ms or so. =/ Will be alright I guess. |
What's the down side to solving this the way rajington did (default to valid)? So it posts back - that's okay since it'll just be validated then right? Maybe I'm missing something... |
That will allow it to submit the form even if it's valid. I think I had a solution on my mind, but haven't got any spare time to spend on VoR last 2-3 weeks. Will first finish the big refactor I started on (new branch). Do let me know if you solve this though. |
It actually doesn't allow the form to submit if it's invalid. I'm not sure why, you're reasoning makes sense. Maybe I didn't change enough? The only line I changed was in the gist that I posted. Even if I change a unique name to a non-unique name and submit the form without blurring the field, it doesn't submit. I would think that in the split-second it takes to check if the name is unique it would let me submit it. Try it yourself when you start working on this one again and make sure I'm not crazy. I can make post a simple project if you need. So it seems that my issue of it flickering after navigating away from the field, and the other issue of it flickering on a submit is different. The solution to on-blur flicker (to make the "loading" response true) did not fix this on-submit flicker issue, is there some other line I should be looking at too? |
Poked around it some more, here is my latest hack: For me this (along with my previous patch) not only removes the flicker, but still prevents you from submitting an incorrect remote validation.... all I tried to do was type in something wrong and then immediately hit submit (without blurring the text field) and it wouldn't let me. Why it works for me, I have no idea. Will it work for anyone else? No idea... Sorry but I'm still very new to RoR and AJAX or even JS in general. I'm just doing this project for a school course. One of these days I'll come back more experienced and contribute. |
It's been a while since I was looking into this specific issue, but I remember it was tricky because when u got more type of validations this gets more apparent. You edit should not work if u ask me because it's the same thing but expressed in the opposite way. I'll have to double check next time though, stay tuned |
..and thanks for the update on your hacking! =) |
It should not be render when the form is being processed/redirected. It seems the AJAX request sometimes is faster - maybe just on localhost, but still bad.
The text was updated successfully, but these errors were encountered: