Application Error – Rails application failed to start properly

If you’re like me at all, you have run into this issue many times trying to upload your favorite Rails app to your webhost. This can be a very annoying and painful process if you do not understand what is going on exactly so I am going to outline a few tips to follow when attempting to release your new app, and if those tips do not work, I have my final tip that is actually quite useful. Here is my checklist:

  • Uncomment ENV[‘RAILS_ENV’] ||= ‘production’ in environment.rb
  • log and tmp directories have CHMOD 777 access.
  • ALL dispatch files in the public directory are CHMOD 755 at least.
  • Make sure the RAILS_GEM_VERSION is set to something installed on the server.
  • If you have unpacked any custom gems, make sure your app is loading them properly.
  • Make sure any gems you are using are installed on the server.
  • Make sure database.yml file is pointed to correct database.

These usually get the job done, and if you still have issues, feel free to comment here and I’ll try and help. One thing I have done in that past that helps out really well is to use a “skeleton” app. Basically what I do is the following:

  1. Run rails <appname>_skeleton where your actual app is going to run. This is the app that your domain name will actually use.
  2. Upload the app your working on to some directory on your host.
  3. The key part is here. You are going to symbolically link folders from inside your skeleton app and the folders you would like to do are:
  • app
  • config (Sometimes I link everything inside except the database.yml file and manage it only on the host)
  • db
  • lib
  • test
  • vendor
  • Everything inside public folder except the dispatch files.

This has come in very useful for me as I do not have to worry about permissions on the dispatch files everything I svn up the public directory and my logs are contained by them self. I can also go into my actual app(not the skeleton one) and just run an svn up. You may have to work with the links a little bit to get it working. If anyone has any comments on this idea or improvements, I would love to hear them.

4 thoughts on “Application Error – Rails application failed to start properly

  1. I have done all the things tht u have written here. But still i m facing the same old problem. My log files are empty. How can i know that my connection with database is correct in server.
    pls help me to resolve this prbolem.

  2. Two things you can try first. Log into the root of the application and type:

    ruby script/console production

    Provided that doesn’t spit out any errors, then try this:

    cd to RAILS_ROOT/public directory and type:

    ruby dispatch.rb

    That should display the webpage’s html right to the console window.

    Try those first to make sure the app isn’t experiencing any other issues

  3. I was wondering, I guess my problem is with gems not being installed on the server! especially that I’m using shared hosting. You know what’s the best way to install gems on shared hosting?

  4. I think the best way to use gems on shared hosting is to unpack(freeze) them into your rails application. You can do this by installing the gem on your local machine, then go into your vendor/plugins directory and type

    gem unpack will_paginate

    This will load the will_paginate gem into your application, so it is no longer required on the server.

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: