简体   繁体   English

Heroku&Rails 3.2对不起,出了点问题

[英]Heroku & Rails 3.2 We're sorry but something went wrong

I'm having a really bad day at this: #rails-noob #githubsucks #herokufail #abouttosmashmylaptop. 我今天过得很糟糕:#rails-noob #githubsucks #herokufail #abouttosmashmylaptop。 Ok, I feel better. 好吧,我感觉好些了。

I have created an app using Rails 3.2.12/ruby 1.9.3. 我已经使用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 ). 它在本地运行-完全没有问题-尽管我遇到了一些github.com问题,但我已经在github上进行了本地保存(请参阅此问题Git复制-找不到接收包 )。 So I tried to deploy to Heroku locally, ie not via github.com. 所以我尝试在本地部署到Heroku,即不通过github.com。 It seems to work - there are no obvious issues, but then when I try to actually open the application (ie 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 Heroku状态:生产或开发中没有已知问题
  2. Heroku run rake db:migrate Heroku运行rake db:migrate
  3. Heroku pg:reset (followed by #2) Heroku pg:reset(接着#2)
  4. Checking "gem 'pg'" is in the gemfile for production (although I still have sqlite3 for development) 在生产文件的gemfile中检查“ gem'pg'”(尽管我还有sqlite3用于开发)
  5. I switched 'config.assets.compile = false' to 'true' in /config/production.rb 我在/config/production.rb中将'config.assets.compile = false'切换为'true'
  6. I'm using Rails 3.2.1, so I've checked I'm on the cedar stack 我正在使用Rails 3.2.1,所以我检查了我在雪松堆栈上
  7. I've also enabled assets in my “application.rb” file – 'config.assets.enabled = true” 我还在“ application.rb”文件中启用了资产–'config.assets.enabled = true”

I've checked Heroku logs etc. multiple times, and there's no issues – everything looks fine - except that there's a 500-error. 我已经多次检查了Heroku日志等,并且没有问题-一切看起来都很好-除非有500错误。 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. 从我阅读的内容来看,似乎以前(Rails 4.0之前)是导致这些错误的Heroku问题,但我似乎都找不到对这两个问题的引用。 it being fixed, or b. 它是固定的,或者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). 更新:根据culix的建议,尽管尝试了打开日志级别,但它似乎并没有改变日志输出(删除了时间代码)。

app[web.1]: Started GET "/" for 124.148.153.24 at 2013-08-11 07:30:40 +0000 app [web.1]:在2013-08-11 07:30:40 +0000上针对124.148.153.24开始获取“ /”

app[web.1]: Processing by StaticPagesController#splash as HTML app [web.1]:由StaticPagesController#splash处理为HTML

app[web.1]: Rendered static_pages/splash.html.erb within layouts/application (2.6ms) app [web.1]:在布局/应用程序中呈现的static_pages / splash.html.erb(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 heroku [路由器]:at =信息方法=获取路径= /主机= genericappname.herokuapp.com fwd =“ 124.148.153.24” dyno = web.1 connect = 2ms服务= 1470ms状态= 500字节= 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]:在1459毫秒内完成了500个内部服务器错误app [web.1]:ActionView :: Template :: Error(未定义的方法[[]]为nil:NilClass

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

app[web.1]: 2: app [web.1]:2:

app[web.1]: 3: 应用[web.1]:3:

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

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

app[web.1]: 6: <%= javascript_include_tag "application" %> app [web.1]:6:<%= javascript_include_tag“应用程序”%>

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

app[web.1]: 8: <%= render 'layouts/shim' %> app [web.1]:8:<%=渲染“布局/填充”%>

app[web.1]: app/v app [web.1]:app / v

However, when I was pushing changes back to Heroku I did pick up two issues: 但是,当我将更改推回Heroku时,确实遇到了两个问题:

  1. I hadn't specifically declared my ruby version in the gemfile (now done); 我还没有在gemfile中明确声明我的ruby版本(现在已经完成); and, 和,
  2. an issue with assets not precompiling - "undefined method '[]' for nil:NilClass". 资产未预编译的问题-“ 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. 我尝试按照Heroku的建议( https://devcenter.heroku.com/articles/rails-asset-pipeline )从命令行手动编译资产,但没有任何乐趣-同样出现nil:NilClass错误。

Related, or an entirely new problem? 相关,还是一个全新的问题?

UPDATE 2: In response to some comments/questions: 更新2:针对一些评论/问题:

  1. culix, I have tried the DevCenter (see #2 in update 1). culix,我已经尝试过DevCenter(请参阅更新1中的#2)。
  2. Log level is set to :debug, but maybe I've done it wrong? 日志级别设置为:debug,但是也许我做错了吗? 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, eg assets or database? 关于NilClass,该应用程序正在开发中,因此它必须是需要在生产环境中加载的东西,例如资产或数据库吗? 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? 我看起来好像在application.css中,并且其他一些帖子似乎表明Rails 3.2中的引导程序可能会成为生产问题,因此欢迎任何建议吗?
  4. I tried both slug and local compilation - neither works. 我尝试了slug和本地编译-均无效。

I'm struggling with lack of Heroku error info to guide me, so directions in that regard welcome also. 我一直在缺乏Heroku错误信息来指导我,因此也欢迎您提供这方面的指导。

UPDATE 3: After running 'run rake assets:precompile' I got a whole heap of Deprecation warnings, along the lines of: 更新3:运行“运行rake asset:precompile”后,我得到了一大堆弃用警告,内容如下:

You have Rails 2.3-style plugins in vendor/plugins! 您在供应商/插件中有Rails 2.3样式的插件! Support for these plugins will be removed in Rails 4.0. 这些插件的支持将在Rails 4.0中删除。 Move them out and bundle them into your gemfile. 将它们移出并将它们捆绑到您的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: 我还运行了“ rake asset:precompile --trace”(我学到了一条新命令!),并在发生错误的地方获得了以下信息:

** Execute assets:precompile:primary **执行资产:预编译:主要

rake aborted! 耙子流产了!

/app/app/assets/stylesheets/application.css has already been required /app/app/assets/stylesheets/application.css已经是必需的

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

Ok, answering my own question in case someone else has a similar problem. 好吧,如果有人遇到类似问题,请回答我自己的问题。 Ultimately I had several issues related to the asset pipeline. 最终,我遇到了与资产管道有关的几个问题。 Somewhere along the line in application.rb file I'd put in some wild card operators (*) in the line config.assets.precompile += %w( various file extensions) , as per the answer to this question ( bootstrap-sass: Undefined variable: "$baseLineHeight" ). 根据这个问题的答案( bootstrap-sass config.assets.precompile += %w( various file extensions) ,在application.rb文件中的某个位置,我在config.assets.precompile += %w( various file extensions)行中放入了一些通配符(*)。 :未定义的变量:“ $ baseLineHeight” )。 Once I removed these, I precompiled the assets again in development ( $ RAILS_ENV=development rake assets:precompile ), and then pushed to git, then to heroku. 删除它们后,我会再次在开发中对资产进行预编译( $ RAILS_ENV=development rake assets:precompile ),然后将其推送到git,然后推送到heroku。

Along the way I also had some issues with heaps of warnings/errors from Webrick - I solved this by specifying the Webrick version in my gemfile: 一路上,我还遇到了来自Webrick的大量警告/错误的问题-我通过在gemfile中指定Webrick版本来解决此问题:

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

If you're new to assets and deployment like me it's definitely worth reading both the RoR ( http://guides.rubyonrails.org/asset_pipeline.html ) and Heroku ( https://devcenter.heroku.com/articles/rails-asset-pipeline ) guides to the asset pipeline, as well as watching Ryan Bate's screencasts #278 and #341. 如果您像我一样不熟悉资产和部署,那么绝对值得阅读RoR( http://guides.rubyonrails.org/asset_pipeline.html )和Heroku( https://devcenter.heroku.com/articles/rails-资产管道指南),以及观看Ryan Bate的#278和#341截屏视频。

Why do you think that error in assets? 您为什么认为资产错误?

You have ActionView::Template::Error, try to debug it, where you call an array on nil object or smthg else. 您有ActionView :: Template :: Error,请尝试对其进行调试,在其中对nil对象或smthg其他对象调用数组。

PS did you pass your migrations? PS,您通过迁移了吗?

heroku run rake db:migrate

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM