rails 3.1 - 强制开发资产像3.0.x一样提供服务?

jsh*_*rpe 5 ruby-on-rails asset-pipeline

我正在升级应用程序.目前3.1.rc8.

问题是,在开发中,在每个请求中,似乎每个资产都通过rails堆栈运行.我们正在谈论,每个图像,js和css文件(并且有很多这些文件).在第一次请求之后,它们都返回304,但它仍然是如此缓慢.

每次请求后都有很多这样的事情:

Started GET "/assets/jquery-ui-1.8.16.custom.css?body=1" for 127.0.0.1 at 2011-08-30 15:36:21 -0400
Served asset /jquery-ui-1.8.16.custom.css - 304 Not Modified (0ms)

Started GET "/assets/yui.css?body=1" for 127.0.0.1 at 2011-08-30 15:36:21 -0400
Served asset /yui.css - 304 Not Modified (0ms)
Run Code Online (Sandbox Code Playgroud)

如何在开发中使资产像在3.0.x中那样提供服务?

我也使用这些标签来防止我的css/js被编译成dev中的单个文件:

= stylesheet_link_tag 'application', :debug => Rails.env.development?
= javascript_include_tag 'application', :debug => Rails.env.development?
Run Code Online (Sandbox Code Playgroud)

这是我的application.rb

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

require 'rails/all'

if defined?(Bundler)
  Bundler.require(:default, :assets, Rails.env)
end

module Fooapp
  class Application < Rails::Application
    config.encoding = "utf-8"

    config.filter_parameters += [:password, :password_confirmation]

    config.assets.enabled = true

    config.assets.version = '1.0'
  end
end
Run Code Online (Sandbox Code Playgroud)

和development.rb:

Fooapp::Application.configure do

  config.cache_classes = false

  config.whiny_nils = true

  config.consider_all_requests_local       = true
  config.action_controller.perform_caching = false

  config.action_mailer.raise_delivery_errors = true

  config.active_support.deprecation = :log

  config.action_dispatch.best_standards_support = :builtin

  config.assets.compress = false

  config.assets.debug = true
end
Run Code Online (Sandbox Code Playgroud)

jsh*_*rpe 0

我所看到的缓慢主要与思考狮身人面像(在我的 Gemfile 中)有关。在开发过程中,TS 在每个页面请求上加载一些与 I18n 相关的内容。并且每个资产都被视为页面请求。

https://github.com/freelancing-god/thinking-sphinx/blob/v2.0.7/lib/thinking_sphinx/railtie.rb#L29

不管怎样,TS 的维护者知道,该文件在 master 上不再存在。在新版本发布之前,您可以在本地注释掉这两行 I18n 行。