Posts Tagged ‘language’

Constructors in Ruby are not guaranteed to be called

Posted by Rahoul Baruah on June 3rd, 2009 under General, Ruby on Rails and Software Development Tags: , ,  •  3 Comments

Today, Caius made a discovery that shocked me.
He had a class, descending from ActiveRecord::Base, with a custom constructor (initialize method). To debug it, he had the constructor raise an exception. In the console, Thingy.new(params) raised the exception as expected. But wotsit.thingies.find_by_field(value) did not. Even though it was instantiating an [...]