-
Notifications
You must be signed in to change notification settings - Fork 855
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
story: check for duplicate URL on blur #413
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @talklittle, for picking up one of my biggest pet peeve issues.
The code can be extracted a little differently to avoid a dependency, so I left some comments. Thanks!
| checkStoryDuplicate: function(form) { | ||
| var params = $(form).serializeArray(); | ||
| $.post("/stories/check_url_dupe", params, function(data) { | ||
| var da = $.parseHTML(data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate you being consistent with the other functions, but I don't want identifiers like data and da that don't carry any meaning. There's also no need for .parseHTML if the js isn't going to do anything with the DOM, so just .html it right into place.
| @story.check_url | ||
|
|
||
| # ignore other types of errors (e.g., invalid URL format) | ||
| if @story.already_posted_story.blank? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of extracting all of check_url from validate, extract just the part that sets already_posted_story and maybe adds the error about it being submitted recently. Leave the regexp that checks format and adds that error.
I don't want this piece of code to have to know about all the other possible errors on URL and be maintained in sync with the model.
| @@ -0,0 +1,29 @@ | |||
| <div class="form_errors_header"> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please name this file _form_errors rather than run the words together.
82817fe to
c44017c
Compare
|
Great to have this. It might be nice to use |
story: check for duplicate URL on blur
fixes #149