RubyMode provides font-locking, indentation support, and navigation for Ruby code.

It’s included in Emacs 23 and is also available via ELPA. However, those copies have no guarantees of backwards-compatibility, so if you’re having trouble with it on an older Emacs version or XEmacs, you can use the copy that’s included with Ruby, which attempts to be highly compatible. You can get it from Ruby’s trunk like this:

  svn co ruby-mode

Web frontend to that repository:

To enable ruby-mode for most all ruby files, add this to your initialization file

  (add-to-list 'auto-mode-alist
               '("\\.\\(?:cap\\|gemspec\\|irbrc\\|gemrc\\|rake\\|rb\\|ru\\|thor\\)\\'" . ruby-mode))
  (add-to-list 'auto-mode-alist
               '("\\(?:Brewfile\\|Capfile\\|Gemfile\\(?:\\.[a-zA-Z0-9._-]+\\)?\\|[rR]akefile\\)\\'" . ruby-mode))

See also RubyOnRails, EnhancedRubyMode, RakefileMode, RSpecMode

RubyLanguage ProgrammingModes