RubyOnRails

From MyLinuxNotes

Jump to: navigation, search

I just started using this cool framework. Along the way I ran into some quirks.

Mysql Errors

First the names of some of my tables are singular but RoR wants to pluralize them. To disable this "feature" add the fooling line to config/enviroment.rb:

   ActiveRecord::Base.pluralize_table_names = false

   Mysql::Error (#28000Access denied for user 'root'@'localhost' (using password: NO)):

This error was caused by me not having my password in config/database.yml

   Mysql::Error: Lost connection to MySQL server during query: SHOW FIELDS FROM foo

This error was caused be cause I had to install the libmysql-ruby package from Debian. There is no gem package in Debian so use apt-get to install it.


Apache Errors

If you want to serve your site from an Apache Alias declaration like:

   Alias /myrailsapp /path/to/myrailsapp/public

you need to edit /path/to/myrailsapp/public/.htaccess and add this line:

   RewriteBase /myrailsapp

This error is common and easy to fix:

   Application error
   
   Change this error message for exceptions thrown outside of an action (like in Dispatcher setups or broken Ruby 
   code) in public/500.html

This is caused by having the wrong permissions on your rails directory. It needs to be owned by the user that your webserver is running as:

   chown -R www-data.www-data /path/to/myrailsapp

Goodies

Spell checker:

   http://deezsombor.blogspot.com/2005/08/how-to-build-ajax-ed-spellchecker-with.html

Searching:

   http://www.bigbold.com/snippets/posts/show/1691
Personal tools