From 9df747c9f018448a08c298b54ccc59e010f7dd0c Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Tue, 31 Jul 2018 22:16:02 +0900 Subject: Throw if ujs loaded twice I saw two posts of problem about ajax requesting twice on qiita. So I think detecting double loaded earlier make easy to find the problem. https://qiita.com/hot_study_man/items/56dc87ad734cfda68bb6 https://qiita.com/hisas/items/8399aec3a5377bf75017 --- actionview/app/assets/javascripts/rails-ujs/start.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'actionview/app') diff --git a/actionview/app/assets/javascripts/rails-ujs/start.coffee b/actionview/app/assets/javascripts/rails-ujs/start.coffee index 55595ac96f..32a915ac0b 100644 --- a/actionview/app/assets/javascripts/rails-ujs/start.coffee +++ b/actionview/app/assets/javascripts/rails-ujs/start.coffee @@ -9,7 +9,8 @@ } = Rails # For backward compatibility -if jQuery? and jQuery.ajax? and not jQuery.rails +if jQuery? and jQuery.ajax? + throw new Error('If you load both jquery_ujs and rails-ujs, use rails-ujs only.') if jQuery.rails jQuery.rails = Rails jQuery.ajaxPrefilter (options, originalOptions, xhr) -> CSRFProtection(xhr) unless options.crossDomain -- cgit v1.2.3