2

当我在生产环境中启动我的应用程序时,我的所有表单都会向服务器发出双重请求,即使它们没有:remote => true. 直到知道我发现的关于此问题的所有内容都与自 Rails 3.1 以来包含的资产管道有关,问题是资产中的某些文件正在复制某些内容,但我认为不是我的情况,因为它也以正常形式发生(没有 ajax )。

对于网络服务器,应用程序使用的是默认配置的瘦,

这是我对 application.js 清单的要求

//= require jquery
//= require jquery_ujs
//= require jquery.cycle.all
//= require jquery.alphanumeric
//= require jquery.pageless
//= require jquery.ui.min.js
//= require jquery.fastLiveFilter.js
//= require_tree .

这些文件中没有一个在 require_tree 搜索的不同路径中重复。

这是我的生产.rb

Web::Application.configure do
  # Settings specified here will take precedence over those in config/application.rb

  # Code is not reloaded between requests
  config.cache_classes = true

  # Full error reports are disabled and caching is turned on
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true

  # Disable Rails's static asset server (Apache or nginx will already do this)
  config.serve_static_assets = true

  # Compress JavaScripts and CSS
  config.assets.compress = true

  # Don't fallback to assets pipeline if a precompiled asset is missed
  config.assets.compile = false

  # Generate digests for assets URLs
  config.assets.digest = true

  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
  # the I18n.default_locale when a translation can not be found)
  config.i18n.fallbacks = true

  # Send deprecation notices to registered listeners
  config.active_support.deprecation = :notify

  # Amazon SES
  config.action_mailer.delivery_method = :ses
end

这是我的应用程序.rb

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

#require 'rails/all'

#require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "rails/test_unit/railtie"
require "sprockets/railtie"

if defined?(Bundler)
  # If you precompile assets before deploying to production, use this line
  Bundler.require(*Rails.groups(:assets => %w(development test)))
  # If you want your assets lazily compiled in production, use this line
  # Bundler.require(:default, :assets, Rails.env)
end

module Web
  class Application < Rails::Application

    # Custom directories with classes and modules you want to be autoloadable.
    # config.autoload_paths += %W(#{config.root}/extras)
    #config.autoload_paths += %W(#{config.root}/lib)
    config.autoload_paths += Dir["#{config.root}/lib", "#{config.root}/lib/**/"]

    # Configure the default encoding used in templates for Ruby 1.9.
    config.encoding = "utf-8"

    # Configure sensitive parameters which will be filtered from the log file.
    config.filter_parameters += [:password]

    # Enable escaping HTML in JSON.
    config.active_support.escape_html_entities_in_json = true

    # Commented because we don't use AR nor DB
    #config.active_record.whitelist_attributes = true

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

    # Version of your assets, change this if you want to expire all your assets
    config.assets.version = '1.0'
  end
end
4

0 回答 0