Tag: 资产

Rails 3.1资产管道 – 从公共/资产中丢失文件 – 为什么这不是默认值?

在今天下午将我升级的Rails 2.3.x – > 3.1(rc4)应用程序部署到我们的测试环境后,我们所有的样式表和JavaScript文件都返回了404错误。 我们已经将rake资产:预编译任务添加到我们的部署后脚本中,并且需要一段时间来确定资产文件夹为什么没有我们预期的预编译文件。 最后,文件没有被编译,因为默认情况下只处理application.css和application.js(+非JS / CSS文件)。 我们需要更改以下配置值,如下所示: config.assets.precompile += %w( *.js *.css ) 问题:为什么这不是默认值? 我原本预计,任何不必作为清单文件处理的东西都会被复制到公共/资产中。 我在资产管道上阅读的大部分内容基本上是“将您的资产放在应用程序/资产中,配置清单文件,它应该正常工作”。 由于资产:预编译任务没有吐出任何有关它正在做什么的信息,因此需要一段时间才能确定它只是没有查看我们认为会存在的文件。 有什么理由说这对于预编译配置来说不是一个好的价值? 谢谢!

生产中没有服务的铁路资产(另一个资产问题)

我正在使用apache 2.2.15乘客5.1.2导轨4.2.6 ruby​​ 2.3.3 在rails日志中,我得到了 (No route matches [GET] application-xxxxx.js 以及 (No route matches [GET] application-xxxxx.css 我可以在public / assets目录中找到资产。 我的清单: 应用程序/资产/样式表/ application.css.less: /* *= require jquery-ui *= require font-awesome *= require bootstrap_and_overrides *= require awesome-bootstrap-checkbox *= require lists *= require mailgroups *= require general *= require colors *= require print *= require loader *= require […]

rails assets:在slug期间为s3错误预编译:当设置env时,雾提供程序和目录不能为空

我决定通过S3提供rails资产; heroku有很好的教程如何做到这一点。 该网站现在提供来自我的亚马逊桶的资产,但我不确定为什么我必须手动运行heroku run rake assets:precompile在heroku run rake assets:precompile的git push heroku master之后rake assets:precompile 。 运行git push heroku master后, git push heroku master了不在我的桶中的资产以及预编译内容的输出: AssetSync: using default configuration from built-in initializer AssetSync: using default configuration from built-in initializer rake aborted! Fog provider can’t be blank, Fog directory can’t be blank /tmp/build_3vtwfg15g8ajx/vendor/bundle/ruby/1.9.1/gems/asset_sync-0.5.0/lib/asset_sync/asset_sync.rb:29:in `sync’ /tmp/build_3vtwfg15g8ajx/vendor/bundle/ruby/1.9.1/gems/asset_sync-0.5.0/lib/tasks/asset_sync.rake:3:in `block in ‘ Tasks: […]

Rails 3.1 Asset Pipeline – 为什么我要在SCSS文件中使用资产助手?

我刚刚进入资产管道; 我正在使用SASS / SCSS,但我不明白为什么我应该使用资产助手。 例如,如果我有一些CSS / SCSS而不使用资产助手: background-image: url(‘rails.png’); 这样可以正常工作,因为我的.SCSS文件和图像都在资源目录中并可以访问。 这样做有什么意义?: background-image: asset-url(“rails.png”, image); 我知道它会在url中添加“/ assets /”,但如果标准的CSS方式有用,我为什么要使用资产助手呢? 我想我错过了一些东西。 它与部署到生产有关吗?

Rails图像和资产未正确加载

例如,在我的Rails应用程序中,我有类似的东西: .wax_seal { background: url(“wax-seal-small.png”); display: block; height: 100px; margin: 0 auto; width: 92px; } .wax_seal:active { background: url(‘wax-seal-small-broken.png’); } 在我的config/environments/production.rb文件中: # Disable Rails’s static asset server (Apache or nginx will already do this). config.serve_static_assets = true 我手动调用资产的编译: bundle exec rake assets:precompile 并且在名称末尾使用哈希创建文件: wax-seal-small-Uuhqwduhqwdoi234983jewf.png 所以这不起作用: background: url(“wax-seal-small.png”); 但这很好(当我在Chrome中手动输入时): background: url(“wax-seal-small-Uuhqwduhqwdoi234983jewf.png”); 我在这里错过了什么一步? 如何让我的CSS规则添加到那个小哈希? 在config/environments/production.rb添加config.assets.compile = true可以使它工作,但我在Rails指南中读到,由于显着的性能命中,这是一个不好的做法。

我如何在Mailer中使用资产?

我无法在邮件程序中使用任何forms的资产管道,而是使用Mailer本身或视图。 以下生成并清空src图像标记。 空图像标记如下所示: img alt =“Header-general” 以下forms通过模型附加文件并在视图中使用它会附加空图像。 attachments.inline[‘header.jpg’] = ’emails/header-general.png’ … 我确实检查了路径,甚至尝试了多条路径,等等但没有运气。 请帮忙。 在电子邮件中包含图像的任何forms都会有所帮助。 这是生产环境。 Xenium::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 […]

在Rails中获取没有HTML的图像URL

在Rails中有一种方法可以获取图像的URL(通过assets_host)并返回图像的URL吗? 我想在我的Javascript中使用assets_host数据,但我只需要将URL插入JS,而不是整个image_tag。 先感谢您!

Rails资产没有预编译,css在生产中看起来不同

在开发模式下我的rails应用程序工作和看起来完全符合我的要求,但在生产中它在chrome和safari上看起来不同,在safari中徽标图像加载但不是字体,在chrome中加载字体而不是图像加上输入字段有点长,并且在chrome中不对齐,但在开发模式下,它们在chrome中看起来都很棒 我一直搞乱了这一点,并删除了公共/资产几次 rake assets:precompile RAILS_ENV=production 没有成功,预编译没有错误 配置/ application.rb中: # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # — all .rb files in that directory are automatically loaded. config.assets.paths << "#{Rails.root}/assets/fonts" config.assets.paths << "#{Rails.root}/assets/images" config.assets.paths << Rails.root.join("app", "assets", "fonts") config.assets.precompile += %w( .svg .eot .woff […]

Rails不会加载位于生产中的公共目录中的资产

您好我在公共目录中有资产(因为简单) 在布局我加载 在开发中它运作良好,但在生产资产没有加载。 我的发展.rb Web::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 = false config.active_support.deprecation = :log config.action_dispatch.best_standards_support = :builtin config.active_record.mass_assignment_sanitizer = :strict config.active_record.auto_explain_threshold_in_seconds = 0.5 config.assets.compress = false config.assets.debug = true end 我的Production.rb Web::Application.configure do config.cache_classes = false config.consider_all_requests_local = true # default false, zobrazuje errory config.action_controller.perform_caching […]

避免在Rails中预编译资产部分(Regex的黑名单)

我已经看到了一些关于避免在使用Rails管道时预编译各种资产的问题/答案; 但是,我希望通过Regex的数组有效地将黑名单用于路径名匹配以从预编译中排除。 对我来说最常见的是,这通常是一组无论如何都会使预编译失败的部分。