grist
grist

Reputation: 103

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. 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”

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'

Upvotes: 1

Views: 1205

Answers (2)

grist
grist

Reputation: 103

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"). 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.

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:

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.

Upvotes: 1

Stan K.
Stan K.

Reputation: 487

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.

P.S. did you pass your migrations?

heroku run rake db:migrate

Upvotes: 0

Related Questions