1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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
This commit is contained in:
Kazuhiro NISHIYAMA 2018-07-31 22:16:02 +09:00
parent 0f5497499c
commit 9df747c9f0

View file

@ -9,7 +9,8 @@
} = Rails } = Rails
# For backward compatibility # 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.rails = Rails
jQuery.ajaxPrefilter (options, originalOptions, xhr) -> jQuery.ajaxPrefilter (options, originalOptions, xhr) ->
CSRFProtection(xhr) unless options.crossDomain CSRFProtection(xhr) unless options.crossDomain