标签: asset-pipeline

Ruby on Rails:heroku运行rake资产:预编译

请帮我理解究竟heroku run rake assets:precompile是什么.自从我开始在rails上使用ruby之后,我总是在推送到github和heroku之前运行这三个命令:

bundle exec rake assets:precompile

RAILS_ENV=production bundle exec rake assets:precompile

在我推到heroku后,我会跑:

heroku run rake assets:precompile

但是,当我在上次推送到heroku后尝试运行它时,我在不同的文件上遇到了一堆相同的错误.例如:

Warning. Error encountered while saving cache ... can't dump anonymous class ...

为了看看我能解决这个问题,我跑了

heroku run rake assets:cleanheroku run rake assets:precompile一次.问题是一切都运转正常,但我觉得如果有这些警告/错误.请帮我理解.谢谢!

ruby-on-rails heroku asset-pipeline precompile-assets

11
推荐指数
3
解决办法
1万
查看次数

Rails资产管道:如何创建自定义清单文件

我试图从application.js单独创建一个自定义清单javascript文件.我从application.js获取代码并将其粘贴到我称为"other_manifest.js"的新文件中,并放在assets/javascrips目录中.这是代码:

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails sprockets asset-pipeline ruby-on-rails-4 ruby-on-rails-4.1

11
推荐指数
1
解决办法
1975
查看次数

Rails 3.1.1资产预编译 - rake中止

编辑:其他人有什么建议吗?我完全难过了!!!

我有一个应用程序,其中所有资产编译得很好,但在第二个应用程序,当我运行时:

RAILS_ENV=production rake assets:precompile --trace
Run Code Online (Sandbox Code Playgroud)

我收到以下消息:未定义的方法`目录?' 为零:NilClass

请帮忙.当我查看public/assets目录时,我看到图像文件已经预编译但没有js或css文件.

以下是完整的终端输出:

=> RAILS_ENV=production rake assets:precompile --trace
/Users/swamiatma/.rvm/gems/ruby-1.9.2-p290@lasource/gems/rack-1.3.4/lib/rack/backports/uri/common_192.rb:53: warning: already initialized constant WFKV_
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/Users/swamiatma/.rvm/rubies/ruby-1.9.2-p290/bin/ruby /Users/swamiatma/.rvm/gems/ruby-1.9.2-p290@lasource/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
/Users/swamiatma/.rvm/gems/ruby-1.9.2-p290@lasource/gems/rack-1.3.4/lib/rack/backports/uri/common_192.rb:53: warning: already initialized constant WFKV_
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:primary
rake aborted!
undefined method …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails precompile ruby-on-rails-3.1 asset-pipeline

10
推荐指数
2
解决办法
8176
查看次数

Rails 3.1.1资产管道Heroku缓存问题

简而言之,问题是在开发模式下我们会对CSS或JS文件进行更改,但总会获得这些文件的缓存/旧版本.我所做的一切都没有任何效果.我检查了几十次配置并尝试了配置值的每个组合,但始终保持得到相同的结果:过时/缓存文件.我必须实际运行在生产模式,并在每次更改后重新启动服务器进行测试.

我花了好几天在这个问题上撕扯我的头发,看了几十个关于资产管道的stackoverflow问题,但从来没有找到解决它的问题,所以我想我会把它发布给后人.

我们使用Heroku并预编译我们的资产,因为Heroku无法为我们预编译(我们也使用了设计,这显然是heroku预编译失败的原因).因此,为了将我们的预编译资产推送到Heroku,我们必须检查它们到git.

这是问题所在.

当我们升级到Rails 3.1.1资产预编译生成的文件时,无论是否有名称中的MD5哈希.我没有想太多,并继续检查所有这些文件,所以我可以推送到heroku.一段时间后,我注意到在开发模式下缓存结果的问题.没有MD5哈希的预编译和签入资产作为静态文件从/ public/assets提供,这使我们无法看到我们在/ app/assets中进行的任何更改.

终于意识到这一点后,我运行了git rm/public/assets,一切都运行了.所以外卖是:小心检查资产到git!

把这变成一个问题:其他人如何做到这一点?我错过了一些明显的东西吗 我真正喜欢的是Heroku为我预编译我的资产,但是我收集的数据库连接错误是因为设计而失败.我曾希望Rails 3.1.1修复此问题,但事实并非如此.

ruby-on-rails heroku asset-pipeline

10
推荐指数
1
解决办法
6042
查看次数

application.css不作为资产

编辑4,5和6

8个小时,欢迎任何更多的想法:)也许这个错误已经知道并解决了,但我得到了我在编辑2和3中描述的行为,当你在app/assets/stylesheets中的.css.erb文件中有这个时:

li {
    background-image: url(<%= asset_path "logo_80px_80px.png" %>);
}
Run Code Online (Sandbox Code Playgroud)

问题部分似乎是asset_path方法调用,但.css.scss也打破了它:

li {
    background-image: url(image-path("logo_80px_80px.png"));
}
Run Code Online (Sandbox Code Playgroud)

我的GemFile是:

source 'http://rubygems.org'

gem 'rails', '3.1.3'
gem 'pg', '0.11.0'
gem 'gravatar_image_tag', '1.0.0.pre2'
gem 'will_paginate'
gem 'rake'
gem 'jquery-rails'
gem 'nested_form'
gem 'acts-as-taggable-on'

gem 'sass-rails'
group :assets do
  gem 'coffee-rails', '~> 3.1.0'
  gem 'uglifier', '>= 1.0.3'
end

group :development do
  gem 'rspec-rails', '2.5.0'
  gem 'annotate', '2.4.0'
  gem 'faker', '0.3.1'
end


group :test do
  gem 'rspec', '2.5.0'
  gem 'webrat', '0.7.1'
  gem 'factory_girl_rails', '1.0'
end …
Run Code Online (Sandbox Code Playgroud)

css ruby-on-rails erb pre-compilation asset-pipeline

10
推荐指数
2
解决办法
1万
查看次数

Heroku*.js不是预编译错误

我在Heroku Cedar堆栈上使用Rails并且在编译资产时没有抛出任何问题,但后来我得到了500个内部服务器错误:

2012-06-25T23:22:59+00:00 app[web.1]: ActionView::Template::Error (bootstrap-datepicker.js isn't precompiled):
Run Code Online (Sandbox Code Playgroud)

知道可能导致这种情况的原因吗?这是我包含的javascript文件(除了我在本地下载)https://github.com/eternicode/bootstrap-datepicker/blob/master/js/bootstrap-datepicker.js

我将它包含在我的application.html.erb中,如下所示:

<%= javascript_include_tag "bootstrap-datepicker" %>
Run Code Online (Sandbox Code Playgroud)

是因为它不是coffeescript文件吗?任何帮助表示赞赏!

ruby-on-rails heroku ruby-on-rails-3 asset-pipeline cedar

10
推荐指数
1
解决办法
4212
查看次数

Manifest.yml没有使用资产进行更新:预编译 - Rails 3.2.6

我正在尝试确保使用Rails资产管道提供压缩的css和js文件.我已经很好地完成了所有工作并且事情正在快速预编译 - 并且还愉快地同步到S3,我使用亚马逊的CloudFront CDN为他们提供服务.

我正在提供application.css和application.js,如下所示:

= stylesheet_link_tag "application"
= javascript_include_tag "application"
Run Code Online (Sandbox Code Playgroud)

问题,简而言之:应用程序布局中没有输出MD5后缀文件 - 只有原始application.css和application.js

这有点陌生:所有图像都有MD5标记.CSS/JS文件没有.

这是我的production.config:

 config.action_controller.perform_caching = true

  # Specifies the header that your server uses for sending files
  config.action_dispatch.x_sendfile_header = "X-Sendfile"
  config.assets.compress = true
  # Fallback to compile on demand
  # config.assets.compile = true
  #config.assets.precompile += %w(application.css application.js)
  # Generate digests for assets URLs
  config.assets.digest = true
  #push the assets to amazon
  config.action_controller.asset_host = Proc.new { |source, request|
    if request.ssl?
      "https://tekpub-assets.s3.amazonaws.com"
    else
      "http://tekpub-assets.s3.amazonaws.com"
    end
  } …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails-3 asset-pipeline

10
推荐指数
1
解决办法
3375
查看次数

开发模式下的资产编译速度慢

我有一个包含数百个咖啡脚本文件的大型rails应用程序.

有时当我在coffeescript文件中进行微小更改或切换分支时,整个资产都被预编译,我必须等待很长时间才能加载页面:

Started GET "/assets/application.js" for 127.0.0.1 at 2013-01-11 19:39:45 +0100
Compiled sprockets/commonjs.js  (0ms)  (pid 18142)
Compiled jquery.js  (2ms)  (pid 18142)
Compiled jquery_ujs.js  (0ms)  (pid 18142)
Compiled underscore.js  (0ms)  (pid 18142)
Compiled backbone.js  (0ms)  (pid 18142)
Compiled backbone_rails_sync.js  (0ms)  (pid 18142)
Compiled handlebars.runtime.js  (0ms)  (pid 18142)
Compiled moment.js  (0ms)  (pid 18142)
...and so on
Run Code Online (Sandbox Code Playgroud)

我使用以下资产配置config/development.rb:

# Do not compress assets
config.assets.compress = false

# Expands the lines which load the assets
config.assets.debug = false
Run Code Online (Sandbox Code Playgroud)

当我设置时,config.assets.debug = false …

javascript ruby ruby-on-rails asset-pipeline

10
推荐指数
2
解决办法
3726
查看次数

iCheck复选框不显示

我无法在任何浏览器中显示iCheck iCheckbox插件.

这是一个jSFiddle.iCheck依赖于jQuery 1.7+.

http://jsfiddle.net/jmj3M/2/

我没有任何选项初始化它:

$(".ex-f").iCheck();
Run Code Online (Sandbox Code Playgroud)

正如您所看到的那样,如果您检查DOM,则输入元素将被iCheckbox div包装.但是,<input><ins>元素的不透明度都设置为0.

通过jQuery改变它们的不透明度,你得到这个:http://jsfiddle.net/buRq7/

不幸的是,它仍然无效.有没有人有任何建议或经验让这个工作?

我正在使用rails 4和资产管道.

编辑: 我只是意识到我没有选择库(纯JS)作为的jsfiddle框架选项,似乎即使不改变不透明度的工作(见:http://jsfiddle.net/buRq7/5/).但是,文档明确说明它依赖于jQuery(或Zepto).将框架选项切换到jQuery 1.10.1会导致iCheckbox再次无法运行...不确定为什么会这样.

checkbox jquery ruby-on-rails asset-pipeline icheck

10
推荐指数
2
解决办法
1万
查看次数

在Rails 4中放置Web worker文件的位置?

HTML5 Web Workers通常依赖于外部脚本importScripts().这些脚本应该放在Rails 4的哪个位置,以便它们按照资产管道正常缩小,但仍能正常工作?

使用需要解决的资产管道时存在一些问题:

  1. 外部脚本(如果置于其下)vendor/assets默认情况下不由资产管道处理(在Rails 3中不是这种情况).
  2. 如果脚本放在下面app/assets,则需要将它们包含在内application.js以便进行处理.但是,工作文件不应包含在组合输出中(即application-[digest].js).
  3. 如果脚本包含在资产配置中,则生成的文件将在其文件名中包含摘要.要加载工作者,需要向浏览器提供其路径(例如new Worker('myWorker.js'),我们如何找到路径?(我试过asset_path,但它没有用).
  4. 就像在3中一样,工作人员在调用时需要按名称引用其他文件importScripts().我们如何找到加载的路径?

asset-pipeline ruby-on-rails-4

10
推荐指数
1
解决办法
830
查看次数