-
Notifications
You must be signed in to change notification settings - Fork 404
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
Fix remote uniqueness validation because of double slash #532
Conversation
This fixes an issue I had: Started GET "/uniqueness?case_sensitive=true&user%5Bemail%5D=beat.besmer%40gmail.com&_=1367362834432" for 127.0.0.1 at 2013-05-01 01:00:45 +0200 ActionController::RoutingError (No route matches [GET] "/uniqueness"): The problem was that the url would contain two slashes `//` (JS Console) JSCONSOLE> ClientSideValidations.remote_validators_url_for('uniqueness') "//localhost:3000//validators/uniqueness" Also see <http://stackoverflow.com/questions/15903572/actioncontrollerroutingerror-no-route-matches-get-uniqueness>
I think this just fixes the single usecase. If the url being used ends in a slash then you end up with a double slash issue. Instead there needs to be a way to normalize the url to ensure both cases are covered |
It is true that it did fix the problem in my case. Since I ran into the issue using the gem out-of-the box, I am wondering if I am not using the gem correctly. So having a I am not sure if the prefix should result in:
Could you maybe clarify this. I guess that using an array and then joining the entries would also solve the problem. ['a', 'b', 'c'].join('/');
// Result: a/b/c |
So I was having this issue with the double slashes but it was because
I fixed it by simply assigning it null in one of my own JavaScript files:
|
What @ddarren did works perfectly.
Apparently the remote_validators_prefix is a blank string using a localhost, the previous code just check if it is blank, and in that case automatically set it to null (this I also think solve all the other issue). What do you think @bcardarella ? Best |
@bcardarella what do you think? |
Isn’t this a dupe of #513? |
So CoffeeScript is supposed to compile the "?" existential operator down to a null or undefined check, but it's just doing null. Sounds like a bug in coffeescript tbh (I looked into this myself a bit). At any rate, a full null or undefined check is the appropriate solution, here: if ClientSideValidations.remote_validators_prefix? |
This fixes an issue I had:
The problem was that the url would contain two slashes
//
(JS Console)Also see http://stackoverflow.com/questions/15903572/actioncontrollerroutingerror-no-route-matches-get-uniqueness