Mar*_*sic 12 ruby ruby-on-rails heroku ruby-on-rails-3 asset-pipeline
本周开始使用资产管道运行最新的rails 3.2.2.对于资产,我希望在将应用程序推送到heroku时编译资产(而不是必须在repo中手动编译和存储已编译的资产).文档表明这应该自动发生.
我遇到的问题是当我运行git push heroku master
它时似乎根本不运行rake assets:precompile
任务.资产永远不会被编译.这是我得到的输出:
-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.1.rc.7
Running: bundle install --without development:test --path vendor/bundle --binstubs bin/ --deployment
Using rake (0.9.2.2)
.......
.......
Your bundle is complete! It was installed into ./vendor/bundle
Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
-----> Rails plugin injection
Injecting rails_log_stdout
Injecting rails3_serve_static_assets
-----> Discovering process types
Procfile declares types -> web
Default types for Ruby/Rails -> console, rake, worker
-----> Compiled slug size is 61.7MB
-----> Launching... done, v30
[appname] deployed to Heroku
Run Code Online (Sandbox Code Playgroud)
我在application.rb中启用了资产管道
require File.expand_path('../boot', __FILE__)
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "sprockets/railtie"
Bundler.require *Rails.groups(:assets) if defined?(Bundler)
module Appname
class Application < Rails::Application
# ...
# Enable the asset pipeline
config.assets.enabled = true
# Do not boot the app when precompiling assets
config.assets.initialize_on_precompile = false
end
end
Run Code Online (Sandbox Code Playgroud)
有谁知道可能导致问题的原因是什么?如果需要,我很乐意为您提供更多代码.如果我运行heroku info
它表明我正在Cedar堆栈上运行.
我不得不开始config.assets.compile = true
停止在生产中接收500个错误,尽管这会在运行时编译资产(我不想要).
Mar*_*sic 10
这似乎现在已经解决了.我认为这是由于Rakefile没有加载资产造成的:生产中的预编译任务.
rakefile正在加载黄瓜和rspec宝石的任务,这些宝石没有捆绑到生产中.因此资产:预编译任务在生产中不可用,因此heroku不会尝试运行它.
我将测试任务包装在环境检查条件中,如下所示:
if %(development test).include?(Rails.env)
require 'rspec/core'
require 'rspec/core/rake_task'
end
Run Code Online (Sandbox Code Playgroud)
如果您的Rakefile中有任何错误,那么将完全跳过预编译步骤.对我来说,我指的是仅在我的测试和开发环境中加载的依赖项,而不是生产,因此rakefile是轰炸.
使用@ Lecky-Lao的建议为我工作.
heroku run rake -T --app staging-hawkmo
Running `rake -T` attached to terminal... up, run.1
rake aborted!
cannot load such file -- jasmine-headless-webkit
Run Code Online (Sandbox Code Playgroud)
一旦我看到它就像在环境测试中包装Rakefile要求一样简单.
归档时间: |
|
查看次数: |
5008 次 |
最近记录: |