Archive

Posts Tagged ‘ruby-on-rails’

Praise for Railstutorial.org

2010/06/25 Comments off

A couple of weeks back I discovered a great tutorial on Ruby on Rails by Michael Hartl at http://www.railstutorial.org

The tutorial takes you through the steps of building a Twitter-like application (not a client!) from scratch. Aside from learning Ruby on Rails, this tutorial also teaches other useful technologies, techniques and best practices, such as:

  • Behaviour driven development (BDD) using RSpec for unit, integration and functional testing
  • Version control using Git
  • Deployment using Heroku
  • Basics of web design (CSS, Ajax)
  • Setting up a database (the tutorial uses the lightweight SQLite3 format, but this can be ported to ‘real’ databases quite easily with Rails)
  • Generating fake data for the test/staging database as well as the unit testing database

sloccount (SLOC: source lines of code) for the complete tutorial’s source code:

$ sloccount .
...
SLOC    Directory       SLOC-by-Language (Sorted)
1182    spec            ruby=1182
361     app             ruby=361
167     vendor          ruby=167
141     config          ruby=141
109     db              ruby=109
35      script          ruby=35
...

How to read these results?

  • app: The actual application is less than 400 lines of code (this even includes the generated HTML)! Try that using Java or ASP.NET… 😉
  • spec: Tests are almost 4 times the size of the actual code (~1200 lines). These tests include unit, integration and functional tests!
  • Most of the remaining code is auto-generated Rails code.

You can get my commented sources from GitHub at http://github.com/draptik/railstutorial

If you want to have a look at the application: It is currently deployed at Heroku: http://draptik-railstutorial.heroku.com/

Using a different minor-mode-prefix with Rinari (Emacs Rails)

2010/04/27 Comments off

Rinari is a Ruby on Rails Minor Mode for GNU/Emacs.

Problem: Most key mappings / keyboard shortcuts rely on the hard coded strings “;” and “‘” (I.e. “C-; f c” -> rinari-find-controller). These prefixes are difficult to access on a German keyboard because they require the shift modifier.

Solution: The following code adds a comma to the list of rinari-prefix strings. Add it to your GNU/Emacs configuration file (i.e. ~/.emacs):

(add-to-list 'load-path "~/your-path-to-rinari-source-code/rinari")
;; This patch must appear before the line "(require 'rinari)"!
(defvar rinari-minor-mode-prefixes
(list ";" "'" ",") ;; CHANGE Added comma to prefix list
     "List of characters, each of which will be bound (with C-c) as a rinari-minor-mode keymap prefix.")

(require 'rinari)

Result: We can now access the command “rinari-find-controller” with the key sequence “C-c , f c”.

Side note: I’m all ears for more Emacs-Lispy solutions to this problem. 😉