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 に答える