0

我正在尝试解决我最近遇到的问题,从 github 生产分支部署cap: production deploy:migrations到我的服务器。

我看到一个潜在的解决方案是关注这个页面:http ://www.kudelabs.com/2012/03/28/rails-3-2-cap-deploy-with-assets

但是我在这rake assets:precompile部分遇到了错误,在本地运行它。终端建议我这样做 bundle exec rake assets:precompile,我这样做了,但我得到了以下信息:

root@ubuntu:~/myapp# bundle exec rake assets:precompile
DEPRECATION WARNING: require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead. (called from /usr/lib/ruby/vendor_ruby/activerecord.rb:2)
/usr/bin/ruby1.8 /usr/local/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
DEPRECATION WARNING: require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead. (called from /usr/lib/ruby/vendor_ruby/activerecord.rb:2)
rake aborted!
Received wrong number of arguments. [nil]
/var/lib/gems/1.8/gems/omniauth-1.1.0/lib/omniauth/strategy.rb:136:in `initialize'
/var/lib/gems/1.8/gems/actionpack-3.2.3/lib/action_dispatch/middleware/stack.rb:43:in `new'
/var/lib/gems/1.8/gems/actionpack-3.2.3/lib/action_dispatch/middleware/stack.rb:43:in `build'
/var/lib/gems/1.8/gems/actionpack-3.2.3/lib/action_dispatch/middleware/stack.rb:113:in `build'
/var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/application.rb:282:in `inject'
/var/lib/gems/1.8/gems/actionpack-3.2.3/lib/action_dispatch/middleware/stack.rb:113:in `each'
/var/lib/gems/1.8/gems/actionpack-3.2.3/lib/action_dispatch/middleware/stack.rb:113:in `inject'
/var/lib/gems/1.8/gems/actionpack-3.2.3/lib/action_dispatch/middleware/stack.rb:113:in `build'
/var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/engine.rb:470:in `build_middleware_stack'
/var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/application/finisher.rb:31
/var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `instance_exec'
/var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `run'
/var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:55:in `run_initializers'
/var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `each'
/var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `run_initializers'
/var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/application.rb:136:in `initialize!'
/var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `send'
/var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
/home/christophecompaq/myapp/config/environment.rb:5
/var/lib/gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
/var/lib/gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
/var/lib/gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency'
/var/lib/gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
/var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/application.rb:103:in `require_environment!'
/var/lib/gems/1.8/gems/railties-3.2.3/lib/rails/application.rb:292:in `initialize_tasks'
/var/lib/gems/1.8/gems/actionpack-3.2.3/lib/sprockets/assets.rake:93
/var/lib/gems/1.8/gems/actionpack-3.2.3/lib/sprockets/assets.rake:60
Tasks: TOP => environment
(See full trace by running task with --trace)
rake aborted!
Command failed with status (1): [/usr/bin/ruby1.8 /usr/local/bin/rake asset...]
/var/lib/gems/1.8/gems/actionpack-3.2.3/lib/sprockets/assets.rake:12:in `ruby_rake_task'
/var/lib/gems/1.8/gems/actionpack-3.2.3/lib/sprockets/assets.rake:21:in `invoke_or_reboot_rake_task'
/var/lib/gems/1.8/gems/actionpack-3.2.3/lib/sprockets/assets.rake:29
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
root@ubuntu:~/myapp# 

谁能告诉我问题可能出在哪里?

4

1 回答 1

0

如果这是初始部署,请尝试删除

load 'deploy/assets'

然后尝试

cap deploy:setup
cap deploy:cold

在这种情况下,您的应用程序将被部署但没有任何资产:) 然后您需要添加以下内容:

#to the top of your deploy.rb namespace :deploy block
namespace :assets do
    task :precompile, :roles => :web do
     from = source.next_revision(current_revision)
     if capture("cd #{latest_release} && #{source.local.log(from)} vendor/assets/ lib/assets/ app/assets/ | wc -l").to_i > 0
                    run_locally("rake assets:clean && rake assets:precompile")
                    run_locally "cd public && tar -jcf assets.tar.bz2 assets"
                    top.upload "public/assets.tar.bz2", "#{shared_path}", :via => :scp
                    run "cd #{shared_path} && tar -jxf assets.tar.bz2 && rm assets.tar.bz2"
                    run_locally "rm public/assets.tar.bz2"
                    run_locally("rake assets:clean")
                else
                    logger.info "Skipping asset precompilation because there were no asset changes"
                end
            end

            task :symlink, roles: :web do
                run ("rm -rf #{latest_release}/public/assets &&
                    mkdir -p #{latest_release}/public &&
                    mkdir -p #{shared_path}/assets &&
                    ln -s #{shared_path}/assets #{latest_release}/public/assets")
            end
        end

然后重新检查你的production.rb中是否有这个

config.serve_static_assets = false

# Compress JavaScripts and CSS
config.assets.compress = true

# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = false

# Generate digests for assets URLs
config.assets.digest = true

完成所有这些工作后,更改资产中的一些内容,例如在 application.css 中添加新行,这将告诉“task :precompile”真正预编译并上传新资产,因为添加了新资产..

于 2013-07-27T07:56:39.397 回答