aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/app
diff options
context:
space:
mode:
authorKazuhiro NISHIYAMA <zn@mbf.nifty.com>2018-07-31 22:16:02 +0900
committerKazuhiro NISHIYAMA <zn@mbf.nifty.com>2018-07-31 22:16:02 +0900
commit9df747c9f018448a08c298b54ccc59e010f7dd0c (patch)
treec25113838c202fa4bafb1284d9834f88f9242852 /actionview/app
parent0f5497499cee78c52b14485d102c602884fb20cb (diff)
downloadrails-9df747c9f018448a08c298b54ccc59e010f7dd0c.tar.gz
rails-9df747c9f018448a08c298b54ccc59e010f7dd0c.tar.bz2
rails-9df747c9f018448a08c298b54ccc59e010f7dd0c.zip
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
Diffstat (limited to 'actionview/app')
-rw-r--r--actionview/app/assets/javascripts/rails-ujs/start.coffee3
1 files changed, 2 insertions, 1 deletions
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