4

我在使用heroku时部署相当麻烦。真的不要为什么它不起作用。Heroku上的Ruby on Rails部署 - bootstrap-sass

这里是我的宝石文件:

gem 'rails', '3.2.0' 
gem 'pg' 
group :assets do 
    gem 'sass-rails', '~> 3.2.3' 
end 
gem 'coffee-rails', '~> 3.2.1' 
gem 'uglifier', '>= 1.0.3' 
gem 'jquery-rails' 
gem "rspec-rails", ">= 2.8.1", :group => [:development, :test] 
gem "factory_girl_rails", ">= 1.7.0", :group => :test 
gem "email_spec", ">= 1.2.1", :group => :test 
gem "cucumber-rails", ">= 1.3.0", :group => :test 
gem "capybara", ">= 1.1.2", :group => :test 
gem "database_cleaner", ">= 0.7.1", :group => :test 
gem "launchy", ">= 2.0.5", :group => :test 
gem "devise", ">= 2.0.4" 
gem 'haml-rails', '>= 0.3.4', :group => :development 
gem 'bootstrap-sass', '~> 2.0.2' 

Heroku的日志:

cache: [GET /] miss 
/usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'   
vendor/bundle/ruby/1.9.1/gems/railties-3.2.0/lib/rails/rack/log_tailer.rb:14:in `call' 
/usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service' 
/usr/local/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread' 

简单的应用程序布局

%html 
    %head 
    %title iPinTeam 
    %meta{:charset => "utf-8"} 
    %meta{"http-equiv" => "X-UA-Compatible", :content => "IE=edge,chrome=1"} 
    %meta{:name => "viewport", :content => "width=device-width, initial-scale=1, maximum-scale=1"} 
    %meta{:content => "", :name => "description"} 
    %meta{:content => "", :name => "author"} 
    = stylesheet_link_tag :application, :media => "all" 
    = javascript_include_tag :application 
    = csrf_meta_tags 
%body{:class => params[:controller]} 
.navbar.navbar-fixed-top 
    .navbar-inner 
    .container 
    = render 'shared/navigation' 
#container.container 
    #main{:role => "main"} 
    - flash.each do |name, msg| 
     = content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) 
    = yield 
%footer 

Sorr Ÿ如果是这个问题完全傻了,我有点困惑,为什么它被赋予此错误:(在日志也不少误区:

vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0 
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.0 
etc... 

在Heroku的依然不佳 - 很抱歉,但出了点问题。

认为问题可能是在heroku上使用了gem bootstrap-sass。我已经尝试切换到瘦Web服务器,但它是彻底的混乱:(有人可以帮助我,也许一点点描述错误。如果一些额外的信息将需要立即张贴。谢谢你...

+0

如果没有预编译和部署,是否已经预编译了您的资产。可能更多的日志信息是有用的 – Amar 2012-04-12 13:40:22

回答

10

您需要uplading到Heroku的前预编译的资产。

尝试rake assets:precompile然后上传到Heroku的。

+0

谢谢你的帮助 – 2012-06-11 06:19:44

+0

记得要git add。 – Robert 2015-12-27 16:22:35

3

资产编译其他答案的同一主题, Heroku还在requires以下的行中哟UR 的config/application.rb中

config.assets.initialize_on_precompile = false 

我相信,如果你这样做,你不应该有雪松堆栈(至少我没有必要向)上部署之前运行rake assets:precompile

更新

我将增加对参考这里需要我,因为我也用宝石来设置config.assets.initialize_on_precompile = trueapplication.rb中,所以我通常做了一本手册之前预编译我的资产部署到Heroku。然而,运行后
$ heroku labs:enable user-env-compile -a HEROKU_APP_NAMEreference),
我不需要再运行rake assets:precompile,Heroku为我编译我的资产。我只希望Heroku保持这种功能。

3
  • 耙资产:预编译
  • config.assets.initialize_on_precompile =假 ..... 所有这些方法不适合我的工作。

这个工作对我来说: 去配置/环境/production.rb

变化:config.assets.compile =假

到: config.assets.compile = true

6

I c乌尔德无法查看与Heroku的引导CSS的网站,所以我做了config/environments/production.rb以下更改,更改行:

config.assets.compile = false 

要:

config.assets.compile = true 
+0

这是什么与轨道4一起工作!谢谢 – vladCovaliov 2013-10-22 19:56:12

1

试试这个

https://www.bootstrapcdn.com 

我只是包括这些链接,这对我来说很好。 对我来说这是很好的解决方案。

另外我用:
1. rake assets:precompile; 2. config.assets.compile = true