Archive for the ‘Ruby on Rails’ Category

How to use DISTINCT on a single column of a multi-column select statement

Saturday, December 6th, 2008

I recently came across this problem today of how to perform a SELECT DISTINCT but on a single column of a multi-column select statement. Imagine a database with a COUNTRIES table. The table contains a list of countries and there is also a "Nationality" column (eg. Australia is the country, ...

Understanding blocks in Ruby on Rails

Saturday, December 6th, 2008

Understanding how to use blocks in Ruby is crucial to leveraging the full power of this language. A block, known as a closure in programming theory, is basically just a method without a name, or an anonymous method. All methods in Ruby have the special ability to accept a block as ...