所有javascripts包括两次和ajax请求在Rails中发送两次

时间:2014-03-11 05:56:45

标签: jquery ruby-on-rails ajax ruby-on-rails-4

我很难解决这个问题。我几乎尝试过所有事情,但无法解决我的问题。我可以在源代码视图中看到我的所有javascripts都包含两次。我已从公用文件夹中删除了所有资产,我的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请求都要提交两次。

1 个答案:

答案 0 :(得分:1)

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

<%= javascript_include_tag :application %>

我删除了它,我的应用程序按预期开始工作。这意味着我们将application.js包括两次。我刚删除了这一行,所有事情都得到了解决。