Ruby on Rails Troubleshooting
There are a number of common issues that can occur when implementing Ruby on Rails. Below is a list of common problems people can encounter when initially creating Rails applications.
Contents
Location
Line endings
Error logs
Production log
Sample errors
Development mode
Performance
Rails version
Database connectivity
Language conflict
Symbolic links
Location
The first line of a Rails application CGI file must reference the correct Ruby location. An example is shown below, where "/usr/local/bin" is the directory in which Ruby resides:
If you are developing locally, be sure to change the Ruby directory reference in your CGI file(s) prior to uploading.
Line endings
Script files uploaded to your Linux shared hosting account require Unix line endings for the shell to correctly determine the interpreter. For more information, see Can I use DOS line endings with my Linux hosting account?.
Error logs
Enabling error logs can alert you to CGI-related errors that might otherwise be mistaken for Ruby errors. Such errors would occur prior to Rails being invoked. See the following articles for more information:
How do I enable CGI error collection?
How do I view my CGI error logs?
Production log
The production log can provide trouble shooting information. There is one production log file per Rails application. It is located in the "log" directory of your application.
Sample errors
The following is a typical error you might encounter:
"/tags/lst/"):
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/
lib/action_controller/routing.rb:469:in `recognition_failed'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/
lib/action_controller/routing.rb:459:in `recognize!'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.1.5/lib/ dispatcher.rb:38:in `dispatch'
/home/content/j/h/l/jhlinux/html/cloud/dispatch.cgi:10
What the error communicates is that Rails cannot find the "lst" dispatcher in the "cloud" rails application.
Development mode
Running your application in development mode will generate a large log file, but can be used sparingly to pinpoint problem areas. To change your environment, modify your environment.rb file so that the RAILS_ENV variable is set to the value "development." For more information, see How do I ensure production performance under Hosting Configuration 2.0?.
Performance
If your Rails application is running slow, you can enable FastCGI by making the following change in the .htaccess file of your Rails application "public" directory:
Change
to
Rails version
Currently,
Rails version 1.1.6 is supported in the default directory while Rails 2.2.2 is available in our alternate "development Compatibility errors may also result from having an incompatible version specified in your environment.rb file. This entry will resemble the following:
Freezing Rails gems can ensure application compatibility, although the use of previous Rails versions may put your data at risk. For more information, see What does it mean to freeze Ruby Gems?.
Database connectivity
Your database.yml file should resemble the following:
adapter: mysql
database: [your database name]
username: [your mysql login]
password: [your mysql password]
host: [your mysql server name (not "localhost")]
port: 3306
Language conflict
If you have Java enabled for your hosting account, it will conflict with Rails.
Symbolic links
The symbolic link you created to your application's public directory is where your application resides. For example, http://www.coolexample.com/ruby_appliation/
To create a cleaner URL, utilize either non-primary domains or subdomains that point to this link. When doing so, set "RewriteBase /" in your application's public/.htaccess file. Creating either a non-primary or subdomain will not overwrite your existing content. For more information, see the following articles:
Adding a non-primary domain to your hosting account
Adding a subdomain to your hosting account