我正在升级应用程序.目前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 …Run Code Online (Sandbox Code Playgroud) 我是JRuby和Rails的新手。当我对我的资产进行预编译时,它将用我不感兴趣的垃圾填充日志。
(在/ srv / test / releases / cba9797f510b211ff3568c9bb800ee7a7366c319中)mkdir -p / srv / test / releases / cba9797f510b211ff3568c9bb800ee7a7366c319 / public / assets mkdir -p / srv / test / releases / cba9797adirs / cff9797a5103211 / releases / cba9797f510b211ff3568c9bb800ee7a7366c319 / public / assets / controllers mkdir -p / srv / test / releases / cba9797f510b211ff3568c9bb800ee7a7366c319 / public / assets / controllers mkdir-p / srv / test / releases / cba9797 / c9 / cff7 / c9 / 7ffc / test / …
我目前在使用独角兽的Heroku Cedar堆栈上有一个应用程序.
我还将CloudFront配置为托管我的css/js资产的自定义源.但是,似乎无论我为Rails配置静态/资产的哪种方式,它都不允许我设置Cache-Control,Max-Age或Expires标头.
这很重要,因为标题是与CloudFront一起传递的,如果我无法设置它们,CloudFront将无法正确缓存它们.
我正在将Rails 3应用程序升级到3.2并设置资产管道.这对于css/js来说很棒,但是我并没有真正看到将它用于图像的重点,不幸的是我有大量的参考/images/*.png之类的css等.
有没有办法只为图像禁用资产管道,所以image_tag("x.png")将返回返回<img src="/images/x.png">而不是<img src="/assets/x.png">?谢谢!
ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.1 asset-pipeline ruby-on-rails-3.2
我正在使用bootstrap-rails gem的最新master分支,并试图以与rails资产管道兼容的方式修改默认的bootstrap变量.
我的宝石文件包含了这些宝石
gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git'
gem 'uglifier', '>= 1.0.3'
gem 'less-rails-bootstrap'
Run Code Online (Sandbox Code Playgroud)
我也包含*= require bootstrap_and_overrides在我的application.css档案中.我知道sprockets单独编译每个css文件,因此你不能指望多个css文件能够互相引用.因此,bootstrap_and_overrides.css.less文件包括以下内容:
@import "twitter/bootstrap/bootstrap";
body { padding-top: 80px; }
//background-image: asset-url("background.png"); background-repeat:no-repeat; background-size: cover; }
@import "twitter/bootstrap/responsive";
// Set the correct sprite paths
@iconSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings.png');
@iconWhiteSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings-white.png');
// Set the Font Awesome (Font Awesome is default. You can disable by commenting below lines)
@fontAwesomeEotPath: asset-path('fontawesome-webfont.eot');
@fontAwesomeWoffPath: asset-path('fontawesome-webfont.woff');
@fontAwesomeTtfPath: asset-path('fontawesome-webfont.ttf');
@fontAwesomeSvgzPath: asset-path('fontawesome-webfont.svgz');
@fontAwesomeSvgPath: asset-path('fontawesome-webfont.svg');
// Font Awesome
@import "fontawesome";
// Your custom …Run Code Online (Sandbox Code Playgroud) ruby-on-rails-3 sprockets asset-pipeline twitter-bootstrap ruby-on-rails-3.2
在阅读了这篇文章(推荐阅读)关于不使用HTML5Shiv直接从源代码(几乎)每个人都这样做之后,我试图在我的应用程序中使用Rails 3.2 Asset Pipeline包含html5shiv.js.
我下载了javascript的缩小版和非缩小版.该约定告诉您将第三方文件添加到vendors/assets文件夹中.我现在有两个问题:
1)我应该将哪个版本(缩小或未缩小)添加到vendors/assets/javascrip文件夹中?
2)因为它是条件参考<!--[if lt IE 9]>,我应该如何调用脚本?
我不想将它添加到application.js清单中,因为我想将它保存为单独的文件,我想使用该条件.我有点迷路了!
任何帮助将非常感激.
谢谢
我试图让livereload使用rails 3.2,我遇到了这个问题,其中有一个参考,没有用.css.scss命名导入的sass部分:
Rails:使用带有Asset Pipeline的livereload
这是正确的,导入的SCSS文件应该命名为file.scss而不是file.css.scss吗?
我在CSS中使用Liquid.例如,我有test.css.liquid哪些包含:
body {
background: {{ 'red' }};
}
当我运行时rake assets:precompile,它不是test.css编译但仍然test.css.liquid没有解析Liquid代码.
Sprockets使用Tilt,默认情况下有一个Liquid解析器.我在我的网站上启用了Liquid.
知道什么可能是错的吗?
我尝试使用一些Kendo UI小部件,它们在开发中运行良好.但是当我将我的应用程序部署到Heroku时,它的外观发生了巨大变化.
我用TreeView小部件编写了一个示例页面.这就是它在开发中的呈现方式:

在Heroku的制作中:

可以看出,缺少列表标记(树标记?).
我怀疑这个问题与资产管道有关,因为这样做rake assets:precompile也会破坏开发中的东西(并将rake assets:clean其还原).但这让我感到困惑,因为我的Bootstrap头在开发和生产中都运行良好(尽管ActionController::RoutingError (No route matches [GET] "/assets/Bootstrap/loading.gif")Heroku日志中有一些错误).
Gemfile:
source 'https://rubygems.org'
gem 'rails'
gem "ancestry"
gem "bootstrap-sass"
gem "will_paginate"
gem "bootstrap-will_paginate"
gem "truncate_html"
gem "slim-rails"
gem "kendoui-rails"
group :development, :test do
gem 'sqlite3'
gem 'rspec-rails'
gem "minitest"
platform :ruby do
gem 'therubyracer'
end
end
group :test do
gem 'capybara'
end
group :development do
gem "nifty-generators"
gem "annotate"
end
group :production do
gem 'pg'
end …Run Code Online (Sandbox Code Playgroud) 我想预加载配置(来自".yml"文件).在我的一个初始化文件(config/initializers/facebook.rb)中,我有以下代码行:
FACEBOOK_CONFIG = YAML.load_file("#{Rails.root}/config/facebook.yml")[Rails.env]
Run Code Online (Sandbox Code Playgroud)
因此,它就像"开发"模式中的魅力一样.一旦我切换到生产模式,它一直告诉我,FACEBOOK_CONFIG是我的" facebook.js.coffee.erb"文件的未初始化常量,位于assets/javascript(如果重要),如果我想要"rake assets:precompile".我试过做随机的东西,比如:RAILS_ENV=production bundle exec rake assets:precompile或者
rake assets:precompile:all
,但没有运气
我已经尝试initialize_on_precompile = true为我的生产环境分配" "变量(尽管默认情况下应该是这样),以防万一.
为什么它在生产模式下不起作用(但是,我想强调一点,它在开发环境中起作用(!)).
有人可以帮助那个吗?
assets initialization ruby-on-rails ruby-on-rails-3 asset-pipeline