Troubleshooting a Ruby on Rails Application

From OCS Support Wiki

Jump to: navigation, search

Contents

[edit] Introduction

This guide will walk you through the steps of diagnosing and fixing most common problems with Ruby on Rails applications that won't start.

[edit] General Problems with All Hosting Methods

  • Did you setup your database and enter its details in the config/database.yml file? Remember that we only allow producion mode, so please make sure that you have your database configuration set for that.
  • Are you attempting to run in development mode when your config/database.yml file is setup for production mode?
  • It is ALWAYS a good idea to freeze your Rails application. Please see Freezing_Rails and freeze Rails to your application before further troubleshooting.
  • If you are getting database errors while migrating your data, try:
RAILS_ENV=production rake db:migrate

instead of simply rake db:migrate. This will force production mode.

  • If your Rails application was working but stopped working, you may have problems due to a recent upgrade in Rails (specifically the 2.0 upgrade). If this is the case, please make sure that the line:
RAILS_GEM_VERSION = '1.2.6' unless defined? RAILS_GEM_VERSION

is present and uncommented in your config/environment.rb file. It should be near the top. You can also try version 1.1.6 instead of 1.2.6 if you are still getting the same error. Also, you may have to disable action_web_service. To do so, edit config/environment.rb and make sure the line:

config.frameworks -= [ :action_web_service ]

is uncommented. It may have the phrase :action_mailer in it too, and if it does, remove it if your Rails application sends e-mails.

  • If you're getting an error about soap, please see this mailing list post. Essentially, the workaround is to add:
require 'rubygems'
gem 'soap4r'

at the top of config/environment.rb.

[edit] Hosting Method Specific Troubleshooting

[edit] Mongrel

If your Mongrel won't start, here are some things to check:

  • If you get an error about port already in use, please run:
killall -9 mongrel_rails ruby ruby1.8

via SSH and try again. If that doesn't fix it, cPanel may have allocated the port incorrectly. If this is the case, simply create a new Rails application in cPanel and move (or redeploy) your application to the new location. This will give you a new port.

[edit] FastCGI

  • The dispatch.fcgi or dispatch.cgi has an incorrect path to Ruby. This won't be the case if you used the ocs-install-rails script, but if you developed on another machine, please make sure the path is #!/usr/bin/ruby in all scripts that include a Ruby path at the top (including the dispatch scripts in public folder and the generators and other utilities in the script folder)
  • Make sure that the dispatch.fcgi and dispatch.cgi scripts have 0755 (-rwxr-xr-x) permissions.
  • Make sure that the public directory has the permissions of 755 (-rwxr-xr-x).
  • Make sure the sessions path is writeable. Run chmod 777 tmp/sessions in the Rails instance folder to see if that fixes the problem. If so, we recommend you switch your sessions to database-backed for extra security.
  • Make sure you are accessing the Rails app with a trailing / after the URL, like yoursite.com/rails/ instead of yoursite.com/rails.

If the above does not solve the problem with your Ruby on Rails application, try running dispatch.cgi on the command line via SSH. You can do this by typing:

cd ~/rails_sites/yourapp/public
./dispatch.cgi

Replace yourapp with the name of your Rails instance.

Hopefully, you will get some valuable information as to what is going on.

If not, then check the log/development.log or log/production.log to see if there are any errors being produced.

If you can't solve it from that, please contact us.