资产管道 - 麻烦让我的CSS活着

问题描述 投票:2回答:5

我目前在Ruby on Rails上遇到资产管道问题。

我正在使用电子商务解决方案(Spree),在文档中,文档中有以下内容:

[...]通过使用特殊的预编译任务,您可以显着提高性能。

$ bundle exec rake assets:precompile:nondigest

在开发中使用预编译rake任务将防止在重新加载页面时自动包含对资产文件的任何更改。必须重新运行预编译任务才能使更改可用。

我的问题是,执行命令后,我的所有CSS都必须手动重新编译才能生效。我找不到这个“反向”命令​​。

我试图删除公共/资产然后重新启动,但没有任何作用。

在我的application.rb中,我有这行资产:

config.assets.enabled = true

编辑:我的开发.rb

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

  # In the development environment your application's code is reloaded on
  # every request. This slows down response time but is perfect for development
  # since you don't have to restart the web server when you make code changes.
  config.cache_classes = false

  # Log error messages when you accidentally call methods on nil.
  config.whiny_nils = true

  # Show full error reports and disable caching
  config.consider_all_requests_local       = true
  config.action_controller.perform_caching = false

  # Don't care if the mailer can't send
  config.action_mailer.raise_delivery_errors = false

  # Print deprecation notices to the Rails logger
  config.active_support.deprecation = :log

  # Only use best-standards-support built into browsers
  config.action_dispatch.best_standards_support = :builtin

  # Raise exception on mass assignment protection for Active Record models
  config.active_record.mass_assignment_sanitizer = :strict

  # Log the query plan for queries taking more than this (works
  # with SQLite, MySQL, and PostgreSQL)
  config.active_record.auto_explain_threshold_in_seconds = 0.5

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

  # Expands the lines which load the assets
  config.assets.debug = true
end

如果有人有线索,我会打开(:

谢谢

ruby-on-rails ruby asset-pipeline spree
5个回答
1
投票

通常你可以运行:

$ bundle exec rake RAILS_ENV=development assets:clean

这应该清除任何预编译的资产。听起来你处于开发模式,但如果你正在制作中,请删除RAILS_ENV=development部分。


1
投票

以防万一:你能检查一个名为manifest.yml的文件吗?它应该在你的/assets/目录中。如果存在,您可以看到里面有消化的名称。尝试评论或删除它们,我们会看到......


0
投票

希望您使用版本控制。键入“git diff”或等效文件,以准确查看可能导致应用程序出现这种新行为的文件。


0
投票

Erowlin,当您预编译资产时,您对CSS所做的任何更改都不会被应用。这是因为它已经从application.css / application.js读取,其中所有资产都被压缩为这两个文件。

因此,如果您想对资产进行任何更改,则无法先对其进行预编译。

对于Spree,如果您正在处理不需要触及CSS / Javascript的代码,那么使用您提到的技术的好时机就是。


0
投票

刚刚发现了什么问题:

Spree将徽标图像的名称存储在数据库中。所以,rake tmp:clear不起作用。 CSS似乎没问题,立即应用了更改。

以下是回应:http://osdir.com/ml/spree-user/2012-12/msg00147.html

如果我必须向Spree报告这个错误,或者它不是一个,我不知道。无论如何,这很奇怪。

谢谢你们所有人!

© www.soinside.com 2019 - 2024. All rights reserved.