Ruby on rails rake资产:预编译在本地显示,而不是在S3中显示
Ruby on rails rake资产:预编译在本地显示,而不是在S3中显示,ruby-on-rails,ruby,amazon-s3,asset-pipeline,Ruby On Rails,Ruby,Amazon S3,Asset Pipeline,rake-assets:precompile当前将所有内容放入我的public/assets目录,当时我觉得(在设置S3之后)它会推到Amazon上。我正在使用所述的资产同步 目前,我的应用程序中有此项。rb: class Application < Rails::Application config.assets.enabled = true config.assets.digest = true end 我做错了什么 您必须了解,资产\u sync用于同步您的资产(而不是替换
rake-assets:precompile
当前将所有内容放入我的public/assets
目录,当时我觉得(在设置S3之后)它会推到Amazon上。我正在使用所述的资产同步
目前,我的应用程序中有此项。rb
:
class Application < Rails::Application
config.assets.enabled = true
config.assets.digest = true
end
我做错了什么 您必须了解,
资产\u sync
用于同步您的资产(而不是替换它们)
资产同步 gem本身将允许Rails“本地”发布您的资产(到
/public/assets
),然后它将基本上把它们都推到您的S3存储桶中,复制它们
如报告所述:
在Rails和S3之间同步资源
资产同步构建为与新的Rails资产管道功能一起运行
在Rails 3.1中引入。运行bundle exec rake之后
资产:预编译您的资产将同步到S3存储桶,
可以选择删除未使用的文件并仅上载所需的文件
对
--
修复
关于您的问题,我确信默认情况下,开发资产是动态提供的——这意味着如果您想将它们作为静态(预编译)运行,您必须定义以下内容:
#config/environments/development.rb
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = false #true
这应该使您能够在本地(在开发中)使用预编译的资产,从而允许您使用S3
默认情况下,生产服务于静态资产,这意味着测试
asset\u sync
最适用的方法实际上是部署到生产环境中。但是,您也应该能够使用上面的代码使其在开发中正常工作除非您使用类似asset\u sync的东西,否则复制到s3的事情不会自动发生sorry@FrederickCheung我使用的是asset\u sync
谢谢Rich。这很有效-我的开发资产现在通过S3提供服务。非常感谢你!
#config/environments/development.rb
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = false #true