所有JavaScript都包含两次,而ajax请求在Rails中发送了两次

阿斯纳德·阿塔(Asnad Atta)

我很难解决这个问题。我几乎尝试了所有事情,但无法解决我的问题。我可以在源代码视图中看到,我所有的JavaScript都包含了两次。我已经从公用文件夹中删除了所有资产,而我的application.js.coffee文件如下所示:

#= require jquery
#= require pace
#= require jquery_ujs
#= require jquery-ui-1.10.3.custom.min
#= require jquery.ui.touch-punch.min
#= require bootstrap-select
#= require bootstrap-switch
#= require bootstrap-typeahead
#= require flatui-checkbox
#= require flatui-radio
#= require jquery.tagsinput
#= require jquery.placeholder
#= require turbolinks
#= require underscore
#= require backbone
#= require twitter/bootstrap
#= require bootstrap-switch
#= require flatui-checkbox
#= require share

#= require jquery.remotipart
#= require deal
window.Views = {}
window.Routers = {}

我的application.rb文件是:

require File.expand_path('../boot', __FILE__)

require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env)

module Opendeals
  class Application < Rails::Application
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.

    config.autoload_paths += Dir["#{config.root}/lib/**/"]
    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
    # config.time_zone = 'Central Time (US & Canada)'

    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
    # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
    # config.i18n.default_locale = :de

    # Enable the asset pipeline
    config.assets.enabled = true

    # Don't try to initialize the application on asset compilation.
    config.assets.initialize_on_precompile = true

    # Version of your assets, change this if you want to expire all your assets
    config.assets.version = "3.0"

    # Don't generate folders under app/assets for resources
    config.generators.stylesheets = false
    config.generators.javascripts = false
  end
end

并且我的application.html.erb布局包含以下内容:

<%= javascript_include_tag "https://js.stripe.com/v1/", "application" %>
<%= tag :meta, :name => "stripe-key", :content => STRIPE_PUBLIC_KEY %>
<%= stylesheet_link_tag "bootstrap", media: 'all' %>
<%= stylesheet_link_tag "flat-ui", media: 'all' %>
<%= stylesheet_link_tag "custom", media: "all" %>
<%= stylesheet_link_tag "animate", media: "all" %>

所有ajax请求都提交两次。

阿斯纳德·阿塔(Asnad Atta)

我只是为其他人发布答案,我的应用程序中有一些部分内容是由其他开发人员添加的。我探索了所有的局部,并在局部中发现了这一点。

<%= javascript_include_tag :application %>

我删除了它,我的应用程序开始按预期运行。这意味着我们两次包含了application.js。我刚刚删除了这一行,一切都解决了。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Http.Request(new Request({}))发送了两次

来自分类Dev

AJAX代码两次发送GET请求

来自分类Dev

Apache两次发送POST请求

来自分类Dev

如何两次发送ajax?

来自分类Dev

我的 javascript 文件中的所有内容都需要单击两次才能触发

来自分类Dev

Microsoft Bot在团队中发送响应两次

来自分类Dev

Rails渲染了两次

来自分类Dev

Node.js:系统发送两次POST请求

来自分类Dev

axios发送的请求由Laravel两次运行

来自分类Dev

两次阻止发送请求react-redux(hook)

来自分类Dev

Node.js:系统发送两次POST请求

来自分类Dev

Python Google App Engine。两次发送GET请求

来自分类Dev

提交按钮混乱并两次发送请求(使用烧瓶)

来自分类Dev

可可豆荚的所有源文件都编译两次

来自分类Dev

角度表单提交两次(ajax获取请求)

来自分类Dev

AJAX请求在提交表单时触发两次

来自分类Dev

我的 ajax post 请求被调用了两次

来自分类Dev

Ruby On Rails Ajax提交提交两次

来自分类Dev

Android凌空两次发送数据

来自分类Dev

Firebase两次发送推送通知

来自分类Dev

套接字两次发送数据

来自分类Dev

GWT RequestFactory:发送两次更改

来自分类Dev

jQuery绑定发送表单两次

来自分类Dev

Firebase两次发送推送通知

来自分类Dev

排球请求被击中两次

来自分类Dev

表单GET请求触发两次

来自分类Dev

Firefox两次请求主密码

来自分类Dev

Powershell变量包含两次值

来自分类Dev

闪亮两次