Geeks With Blogs

News
Shelfari: Book reviews on your book blog

.net alternatives by Michel Grootjans

I'm starting to really enjoy what RoR offers out of the box. This framework is really designed around the application lifecycle we all try to reinvent on every project.

Rails

Rails is the framework for web development over a database. Compare it to asp.net on dotnet. However, Rails is much more than a web UI. Read on...

Ease of development

When creating any kind of object, extra files are being generated as well, like helper classes, test classes, database migration scripts, fixtures, ... Most of the quotes that follow are command line commands. Since I wanted to know exactly what's happening, I used only the command line, notepad++ and Firefox.

> rails my_test_project

Generates a complete project structure with MVC, database scripts, environment definitions, test repositories, configuration, ...

Management of multiple environments

With a freshly generated project, you get three environments: development, test and production. You can add as many as you like. Each environment has its own database, which can each be from a different vendor.

MVC

Rails supports the MVC pattern out of the box

> ruby script/generate controller Site index about help

This command generates:

  • A site_controller having index, about and help actions
  • A view for each of these actions
  • A site_helper class
  • A site_controller_test functional test

The three views are instantly up and running

> ruby script/generate model User

This command generates:

  • A user model. Equivalent to what we call an entity
  • A user_test unit test
  • A users test fixture. This is a file where you set up the users you want in the database when running tests
  • A database script for the new entity

Scaffolding is entirely supported:

> ruby script/generate scaffold Post blog_id:integer title:string body:text

> rake db:migrate

The first command will generate the MVC triad necessary to manage posts. The second will generate the database table to persist the actions.

Posted on Tuesday, September 2, 2008 11:37 PM Ruby on Rails | Back to top


Comments on this post: Why I like Ruby on Rails: Part 1

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Michel Grootjans | Powered by: GeeksWithBlogs.net