资产管道在Rails生产环境中不起作用 [英] Asset pipeline not working in rails production environment

查看:67
本文介绍了资产管道在Rails生产环境中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Rails部署到VPS时遇到问题.我的应用程序在开发环境中运行良好,但是当我使用Capistrano进行生产时,遇到了问题.

I'm having an issue deploying to a VPS using Rails. My app works fine in the development environment, but when I push to production using Capistrano, I run into issues.

我正在使用独角兽,rails 3.2.13和ruby 1.9.3

I am using unicorn, rails 3.2.13, and ruby 1.9.3

我遇到的问题是,当我访问生产站点时,出现模板丢失"错误:

The issue I have is when I visit my production site, I get a 'template is missing' error:

Template is missing

Missing template site/index with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :haml]}. Searched in: * "/home/deployer/apps/my-app/releases/20130417030832/app/views" * "/home/deployer/apps/my-app/shared/bundle/ruby/1.9.1/gems/devise-2.2.3/app/views" * "/home/deployer/apps/my-app/shared/bundle/ruby/1.9.1/bundler/gems/piggybak_paypal-b892954868c7/app/views" * "/home/deployer/apps/my-app/shared/bundle/ruby/1.9.1/gems/piggybak_variants-0.0.15/app/views" * "/home/deployer/apps/my-app/shared/bundle/ruby/1.9.1/gems/piggybak-0.6.28/app/views" * "/home/deployer/apps/my-app/shared/bundle/ruby/1.9.1/bundler/gems/rails_admin-b8465f738261/app/views" * "/home/deployer/apps/my-app/shared/bundle/ruby/1.9.1/gems/kaminari-0.14.1/app/views"

因此,我认为这可能是资产预编译问题.在本地开发环境中运行rake asset:precompile时,出现问题:

So, I think it could be an assets precompile issue. When I run rake assets:precompile in my local development environment, I get the issue:

/Users/ac/.rvm/rubies/ruby-1.9.3-p392/bin/ruby /Users/ac/.rvm/gems/ruby-1.9.3-p392/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
[RailsAdmin] RailsAdmin initialization disabled by default. Pass SKIP_RAILS_ADMIN_INITIALIZER=false if you need it.
rake aborted!
FATAL:  password authentication failed for user "deployer"
/Users/ac/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:1216:in `initialize'
/Users/ac/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:1216:in `new'
/Users/ac/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:1216:in `connect'
...

deployer是生产数据库用户的名称,可以在生产名称空间下的database.yml中找到.我不确定为什么要尝试加载它.我肯定是在开发模式下运行服务器.

deployer is the name of my production database user, and is found in database.yml, under the production namespace. I'm not sure why it's trying to load this. I am definitely running the server in development mode.

我也在生产服务器上的unicorn.log文件中注意到了这一点:

I also notce this in my unicorn.log file on my production server:

I, [2013-04-17T04:44:46.626587 #16199]  INFO -- : executing ["/home/deployer/apps/my-app/shared/bundle/ruby/1.9.1/bin/unicorn", "-D", "-c", "/home/deployer/apps/my-app/current/config/unicorn.rb", "-E", "production", {12=>#<Kgio::UNIXServer:fd 12>}] (in /home/deployer/apps/my-app/releases/20130417044320)
I, [2013-04-17T04:44:46.627160 #16199]  INFO -- : forked child re-executing...
/home/deployer/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.3.5/lib/bundler/definition.rb:16:in `build': /home/deployer/apps/my-app/releases/20130417020329/Gemfile not found (Bundler::GemfileNotFound)
  from /home/deployer/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.3.5/lib/bundler.rb:148:in `definition'
  from /home/deployer/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.3.5/lib/bundler.rb:116:in `setup'
  from /home/deployer/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.3.5/lib/bundler/setup.rb:17:in `<top (required)>'
  from /home/deployer/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
  from /home/deployer/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
E, [2013-04-17T04:44:46.777335 #18166] ERROR -- : reaped #<Process::Status: pid 16199 exit 1> exec()-ed

这是我的gemfile:

Here's my gemfile:

source 'https://rubygems.org'

gem 'rails', '3.2.13'

gem 'pg'

gem 'rails_admin', :git => 'git://github.com/sferik/rails_admin.git'

gem 'piggybak', '0.6.28'
gem "piggybak_variants", '0.0.15'
gem 'piggybak_paypal', :git => 'git://github.com/timmyc/piggybak_paypal.git'

gem 'devise'
gem "cancan"

gem 'countries', :require => 'iso3166'

gem "figaro"

gem 'redactor-rails'
gem "carrierwave"
gem 'rmagick', '2.13.2'
gem "mini_magick"
gem "fog", "~> 1.3.1"

gem 'turbolinks'

gem 'tire', '0.5.7' # elastic search

gem 'kaminari'

gem "friendly_id", "~> 4.0.9"
gem 'acts-as-taggable-on', '>= 2.3.1'
gem 'acts_as_list'
gem 'meta-tags', :require => 'meta_tags'


#group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'haml-rails'
  gem 'uglifier', '>= 1.0.3'
#end

group :development do
  gem 'bullet'
  gem 'meta_request'
end

gem 'jquery-rails'

gem "unicorn-rails"

gem 'capistrano'
gem 'rvm-capistrano'

将不胜感激.预先谢谢你.

Thoughts would be much appreciated. Thank you in advance.

推荐答案

您好,您可以将gem放在资产路径之外吗:

hello can u put gem outside asset path :

gem "haml"

gem 'haml-rails'

取消注释资产路径

并捆绑安装

或者您可以参考:

如何让Haml与Rails合作?

这篇关于资产管道在Rails生产环境中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆