FIX: Show error messages when adding permalinks in the admin UI (#12545)
Also, check for uniqueness of permalinks before attempting to save.
This commit is contained in:
parent
c89f97aafe
commit
70970bb791
|
@ -69,9 +69,13 @@ export default Component.extend({
|
||||||
this.set("formSubmitted", false);
|
this.set("formSubmitted", false);
|
||||||
|
|
||||||
let error;
|
let error;
|
||||||
if (e.responseJSON && e.responseJSON.errors) {
|
if (
|
||||||
|
e.jqXHR &&
|
||||||
|
e.jqXHR.responseJSON &&
|
||||||
|
e.jqXHR.responseJSON.errors
|
||||||
|
) {
|
||||||
error = I18n.t("generic_error_with_reason", {
|
error = I18n.t("generic_error_with_reason", {
|
||||||
error: e.responseJSON.errors.join(". "),
|
error: e.jqXHR.responseJSON.errors.join(". "),
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
error = I18n.t("generic_error");
|
error = I18n.t("generic_error");
|
||||||
|
|
|
@ -8,6 +8,8 @@ class Permalink < ActiveRecord::Base
|
||||||
|
|
||||||
before_validation :normalize_url
|
before_validation :normalize_url
|
||||||
|
|
||||||
|
validates :url, uniqueness: true
|
||||||
|
|
||||||
class Normalizer
|
class Normalizer
|
||||||
attr_reader :source
|
attr_reader :source
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue