Aimred Developer Blog May 2008 Archive

Sequel 2.0 Almost Here

Sequel 2.0 Release Candidate has just been released. All deprecated methods have been removed so it’s probably a good idea to check your existing code before porting over.

14th May Cape Town Ruby Brigade Meeting

Don’t forget the next meeting of the Cape Town Ruby Brigade takes place at 19:00 this Wednesday 14th May at the Bandwidth Barn in Cape Town. This months topic will be a report back on the Scotland on Rails conference. More details at the Cape Town Ruby Brigade Google group meeting page.

Instantiating With Sequel::Model

One nice thing about Sequel::Model is that it allows both hash and block instantiation of models.

1 values = { :name => "Bob Roberts" }
2 organisation = values ) do |o|
3 ||= random_organisation_name
4   o.email_address ||= random_organisation_email
5   o.phone_number ||= random_phone_number
6 end

The call to values ) sets the attributes from the hash and then using Ruby’s ||= operator (remember a ||= b is equivalent to a = a || b) in the block we set any attributes not present in the hash.

About Aimred

Aimred is a specialist Ruby and Ruby on Rails development house and consultancy based in Cape Town, South Africa.

We provide Ruby and Ruby on Rails development, consulting and training services to businesses and organisations of all sizes. If you want to find out how we can help you, contact us at