What exactly is Ruby self

Ruby is an object-oriented langauage, a very powerful one. A Ruby class is an object of class Class. And all method calls in Ruby invoke with a receiver, which is the current object. We can refer to the current object by using keyword self, the same as this in Java in term of meaning but [...]

Posted at 3:45 am on October 6, 2008 | leave a comment | Filed Under: Rails | Tagged: | read on

Specifies when Rails validation should be active

I just noticed an error caused by a validation on a model as following:

validates_presence_of [:fname, :lname, :email, :update_reason]

There’s nothing wrong with that except :update_reason. Because :update_reason could actually be empty on creation since its purpose is for modification log only. Thanks to beautiful Rails validation API, the above validation could be fixed as follow:

validates_presence_of [:fname, [...]

Posted at 4:20 am on October 3, 2008 | leave a comment | Filed Under: Rails | Tagged: | read on

About

A polyglot programmer. Developed desktop application with Swing. Working toward web with Rails. Follow me on twitter.

Categories