Ride the Rails: Still skeptical?

Ok, so we had been shouting ourselves hoarse, claiming that Rails is all about developer productivity and joy. So is that all about it?, huh!, was the normal reaction. But isn’t that a big enough reason. Not for many people though.

Yes, we accept that there are some pain points, like hosting Rails applications at shared hosts. No we don’t need those in production, but don’t you wish it was easier to deploy a rails app for a quick review with a client (a client who can’t run it on his own machine). Yes php scores there, just throw the code on the server and you are done. Why do I still run this blog on wordpress and not typo or mephisto? The big reason is that it’s easy to let just apache handle everything.

But things might change soon with the launch of passenger aka modrails.

And the other classic allegation against Rails has been performance. Remember the discussion between JDD and DHH about CPU cycles vs. developer cycles. We are definitely headed in the direction of lesser CPU cycles for our Rails app. Rails2 made some advances towards that and with Ruby1.9 and YARV and Rubinium, we have high expectations. Also you have heard about Ruby Enterprise Edition , haven’t you?

So things might change, when people try to figure out the fastest web language or framwework , the next time around.

I and those around me here, are generally biased towards rails. Ruby makes us happy. For us the pleasure points in Rails were always far more than the pain points. The basic Rails principles of DRY and Convention Over Configuration clicked with us. Ruby’s and Rail’s simplicity and beauty clicked with us. We did not need hosting on shared hosts. We could work with Rails caching to improve performance. No wonder we were one of the early adopters of Rails in India. But today, I would like to thank the critics whose untiring rants have moved Rails in the direction of being much more than what is was a couple of years ago.

Some of those changes have been in rails, but more have been around it. If you would have noticed, most of these development are not in rails as such, but in the ruby ecosystem.

Rails provides developer productivity and joy; ease of deployment; and ever-improving performance. And no, now you don’t need to go back to Java. We knew it, I am just repeating it for you.

Extrapolate this one year old graph for yourself.

So what is your reason for not having rail-ed yet?

Update: Charles Nutter has a post on upcoming Ruby implementations here

 

VinSol’s certified Scrum Master

Aditya is VinSol’s first certified Scrum Master.

Aditya's Scrum Master Certificate

Ever since he completed his training, we have had a much better control over and understanding of the Scrum process that we use for our projects, leading to a much better control over our projects.
Thanks to Aditya, the wall just across my cabin is now full of Product Backlogs, Sprint Backlogs, Burn
Down Charts and post-it notes which move from “not started”, “working” to “done” columns.

Project Dashboard
As it became evident in the Sprint Retrospective meeting, the biggest advantages for me after implementing scrum at VinSol were “More accountability for everybody (whether a chicken or a pig, refer the commited vs. involved Scrum joke)” and
“More insight into the development progress at any point of time”

Sprint Retrospective Meeting
The sprint retrospective meeting looks like we are taking some exam.

 

What the Flock

I downloaded Flock today, just to test create blog posts directly from Flock into socialroots repository, as a part of the project.

But I ended up using it the whole day. Just didn’t feel like going back to FF. Both of them are built on top of the mozilla engine and have the same shortcuts, this really reduce the (psychological and habitual) barriers to the change.

I added a couple of feeds that I used to read via bloglines to Flock; and now i am writing this blog post also in Flock.

Have yet to try out flickr and delicious functions inbuilt in flock.

Even Flock UI seems better than FF ( or is it just that i am liking the change)

Give Flock a try if you still haven’t.

 

emacs for windows: meadow

Meadow is a tool that I came across on my last visit to Japan.
It is a GNU Emacs imlpementation for Windows and is fairly popular in Japan.
Though i had tried the windows version of xemacs before, I like the meadow interface much more.

You can get it here.
There is an english version of the wiki here.

I sometime do a little bit of rails hacking on my windows pc too … so i installed the ruby mode.
If you would want to add ruby-mode, you can find ruby-mode.elc under your ruby installation.
Copy it to lisp/progmodes/ under meadows home.

To customize Meadow further… here is a good link ( tis in japanese, but you should understand the lisp)

 

validating Rails association

Should ActiveRecord add validations based on associations defined in the models?

class User < ActiveRecord::Base
  has_many :posts
end 

class Post < ActiveRecord::Base
  belongs_to :user
end 

If i create an instance of a post with a user_id that does not exist in the Users table, I wish ActiveRecord threw up a validation error on saving this instance of post.
It does not do so by default, so here are the validations that I add to my models to implement this.

class User < ActiveRecord::Base
  has_many :posts
end 

class Post < ActiveRecord::Base
  belongs_to :user
  validates_associated :user
  validates_presence_of :user
end

Now if I try and save a post without a user_id or with a user_id that is not found in the Users table, an exception is thrown.

Till now I always use to create foreign keys in my database, as a safety net. So that the db throws an error if my data is not consistent.
After adding these validations, I hope not to have foreign keys in the database anymore.

 

testing rails application

Have been busy recently comparing Rails 1.1’s integration testing and WATIR and selenium for end-to-end testing a rails application.

The testing scenario is that the webserver is running on a remote Linux box in US, to which we have ssh access.
And we are testing the application from India. So we cannot run the browser on that machine.

We are writing test cases for various parts of the application using each of these tools and then we would compare notes.

A few things however are clear rightaway.

WATIR will test only for IE on windows. Firefox support for watir called firewatir is being built, and is not robust as of now. Also we might need different sets of test scripts for firefox and IE.

Selenium is the easiest to get started in the BrowseBot FITRunner mode; haven’t tried the “driven” mode yet. FIT mode would not allow us to verify values on the screen against those in the db… but then probably those tests should go into the “controller testing”(functional testing) and not be at this level. When we want to test against db for multiple controllers then rails’ integration testing is the probably the best way.

Running selenium in “driven” mode will take some research, for which i have not been able to spare time.

WATIR requires ruby and watir gems to be installed on the client computer. Hence if we want to share UI tests with our non-technical client, Selenium is better since it requires no installation.

From the aspect of writing test cases, WATIR is better than selenium’s FIT mode. Selenium test cases need to be written in html. And there is no control flow in the selenium core, though there is a user contributed library for this.

For certain kind of testing, such as against db values and checking values in session, Rails functional tests and integration tests are great.

Will share more experiences on this when we are through with the exercise.

How has your experience with these tools been?

***********************************
Received this profound quotation in my email today.

“The greatest good you can do for another is not just to share your riches, but to reveal to him his own.”
Benjamin Disraeli
1804-1881, Former British Prime Minister
***********************************