Use Sequel gem to build queries. Much more powerful and ruby-like.