1

I'm having a really bad day at this: #rails-noob #githubsucks #herokufail #abouttosmashmylaptop. Ok, I feel better.

I have created an app using Rails 3.2.12/ruby 1.9.3. It's working locally - no issues at all - and I've saved locally with github, although I'm having some github.com issues (see this question Git duplication - receive pack not found). So I tried to deploy to Heroku locally, i.e. not via github.com. It seems to work - there are no obvious issues, but then when I try to actually open the application (i.e. browse the website) I get the infamous "We're sorry, but something went wrong". Here's what I've tried so far:

  1. Heroku status: no known issues either in production or development
  2. Heroku run rake db:migrate
  3. Heroku pg:reset (followed by #2)
  4. Checking "gem 'pg'" is in the gemfile for production (although I still have sqlite3 for development)
  5. I switched ‘config.assets.compile = false’ to ‘true’ in /config/production.rb
  6. I’m using Rails 3.2.1, so I've checked I’m on the cedar stack
  7. I've also enabled assets in my “application.rb” file – ‘config.assets.enabled = true”</li>

I’ve checked Heroku logs etc. multiple times, and there’s no issues – everything looks fine - except that there's a 500-error. From what I've read it seems there might have previously (pre-Rails 4.0) been a Heroku issue driving these errors, but I can't seem to find reference to either a. it being fixed, or b. how to fix it.

Suggestions?

UPDATE: As per culix's suggestion, I tried to turn on the log level although but it doesn't seem to change the log output (time codes removed).

app[web.1]: Started GET "/" for 124.148.153.24 at 2013-08-11 07:30:40 +0000

app[web.1]: Processing by StaticPagesController#splash as HTML

app[web.1]: Rendered static_pages/splash.html.erb within layouts/application (2.6ms)

heroku[router]: at=info method=GET path=/ host=genericappname.herokuapp.com fwd="124.148.153.24" dyno=web.1 connect=2ms service=1470ms status=500 bytes=643

app[web.1]: Completed 500 Internal Server Error in 1459ms app[web.1]: ActionView::Template::Error (undefined method `[]' for nil:NilClass

app[web.1]: (in /app/app/assets/stylesheets/application.css)):

app[web.1]: 2:

app[web.1]: 3:

app[web.1]: 4: <%= full_title(yield(:title)) %>

app[web.1]: 5: <%= stylesheet_link_tag "application", :media => "all" %>

app[web.1]: 6: <%= javascript_include_tag "application" %>

app[web.1]: 7: <%= csrf_meta_tags %>

app[web.1]: 8: <%= render 'layouts/shim' %>

app[web.1]: app/v

However, when I was pushing changes back to Heroku I did pick up two issues:

  1. I hadn't specifically declared my ruby version in the gemfile (now done); and,
  2. an issue with assets not precompiling - "undefined method '[]' for nil:NilClass". I tried manually compiling assets from the command line as per Heroku's advice (https://devcenter.heroku.com/articles/rails-asset-pipeline) but no joy - same nil:NilClass error.

Related, or an entirely new problem?

UPDATE 2: In response to some comments/questions:

  1. culix, I have tried the DevCenter (see #2 in update 1).
  2. Log level is set to :debug, but maybe I've done it wrong? I'm learning as I go - how can I get log info from production when it won't load?
  3. In regards to the NilClass the app is working in development, so it has to be something that needs to be loaded in production, e.g. assets or database? I’ve updated the error generated above – I may have cut off some crucial information previously. I looks like it’s in the application.css and some other posts seem to suggest that bootstrap in Rails 3.2 can be an issue for production so any suggestions welcome?
  4. I tried both slug and local compilation - neither works.

I’m struggling with lack of Heroku error info to guide me, so directions in that regard welcome also.

UPDATE 3: After running 'run rake assets:precompile' I got a whole heap of Deprecation warnings, along the lines of:

You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them into your gemfile.

But my vendor/plugins folder is empty?

I have also run 'rake assets:precompile --trace' (I learnt a new command!) and got the following around where the error occurs:

** Execute assets:precompile:primary

rake aborted!

/app/app/assets/stylesheets/application.css has already been required

/app/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:267:in `circular_call_protection'

4

2 回答 2

1

好的,如果其他人有类似的问题,请回答我自己的问题。最终,我遇到了与资产管道相关的几个问题。config.assets.precompile += %w( various file extensions)根据这个问题的答案(bootstrap-sass: Undefined variable: "$baseLineHeight" ) ,在 application.rb 文件中的某处,我会在该行中放入一些通配符运算符 (* )。一旦我删除了这些,我在开发中再次预编译资产($ RAILS_ENV=development rake assets:precompile),然后推送到 git,然后推送到 heroku。

在此过程中,我还遇到了来自 Webrick 的大量警告/错误的问题——我通过在我的 gemfile 中指定 Webrick 版本解决了这个问题:

group :development do
   gem 'webrick', '~> 1.3.1'
end

如果您像我一样对资产和部署不熟悉,那么绝对值得阅读 RoR(http://guides.rubyonrails.org/asset_pipeline.html)和 Heroku(https://devcenter.heroku.com/articles/rails- asset-pipeline ) 资产管道指南,以及观看 Ryan Bate 的截屏视频 #278 和 #341。

于 2013-08-26T02:02:12.737 回答
0

为什么你认为资产中的错误?

你有 ActionView::Template::Error,尝试调试它,你在 nil 对象上调用一个数组或 smthg 其他。

PS你通过你的迁移了吗?

heroku run rake db:migrate
于 2013-08-11T08:26:46.523 回答