There are two things that i am especially looking forward to in Rails 2.3.
I use named_scope like all the time now since i figured out what they are and how useful they can be. I often find myself doing something like this:
named_scope :ordered, :order => 'surname ASC, first_name ASC'
Just so that i can append .ordered to any other named_scope and get my objects out in a sensible order. Well in Rails 2.3 we're going to have a default_scope
default_scope :order => 'surname ASC, first_name ASC'
Marvellous! :D
The other thing i'm looking forward to is the new super-slick render for partials. No more
render :partial => 'articles/article', :locals => { :article => @article }
render :partial => 'articles/article', :collection => @articles
Those now become the splendidly simple
render @article
render @articles
Thanks to Ryan's Scraps for explaining to me how that's going to work!
Posted: November 21st, 2008
Categories:
geeky,
ruby on rails
Comments:
View Comments.
Who knew that coding could be such a social activity! I really like GitHub, with its ability to fork people's code base, apply your own changes, offer it up to be merged back in, see the difference logs, comment on the difference logs … ah, now that last one's genius!
Somebody happened upon this quiet little commit from DHH … yes, the DHH, creator of Ruby on Rails. The bright spark goes and posts it to Reddit, prompting the world and its duck to chime in with an opinion! It's quite funny reading through the comments, both on Reddit and on GitHub.
What does the commit do? Not a lot. It's what we call syntactic sugar: aliasing something in code as something else. It means we'll be able to do this:
['a', 'b', 'c', 'd'].third
=> 'c'
Of course, i have an opinion too. I can see why it could be useful, but i don't really think it is worthy of being in the Rails core code. I doubt i will ever use it. I also agree with the person who says it widens the gap between Ruby and Rails. When Array#first is available in Ruby, people will wonder why Array#second is not.
I do wonder, if anyone other than DHH had submitted this 'patch', whether it would have been accepted into core Rails.
After laughing at this thread over lunch today, one of my colleagues sent me an instant message:
Coffee.third?
I replied:
return true
I think it's good that people are looking at the commits, seeing what's going into Rails, and having their say about it. This is community-driven development at its best! Cheers, GitHub! :)
Update: DHH has responded! It now only goes up to fifth … but Array#forty_two has been added in as compensation! DHH calls it accessing "the reddit".
Posted: November 19th, 2008
Categories:
geeky,
interesting,
ruby on rails,
social
Comments:
View Comments.
The following was knocked up when i was ill in bed, possibly feeling a tiny bit hysterical! The supposition is that, since Cucumber is multilingual, it would be trivial to make it understand LOLCAT. I quite like the fantasy of employing a team of cats to test MyChores for me! :) Whether i actually go on to test in this way is actually doubtful. It's so hard to remember how i mis-spelled things!

moar funny pictures
Thanks to Frédérique in NZ for the source photo.
OH HAI: I CAN HAS LOGIN PLZ
AS NICE FRENDLEE KITTEH
I CAN PLZ HAS LOGIN ON TEH MYCHORES
SO DAT I CAN HAS HUGS TIEM AN PLAY TIEM AN SLEEP TIEM AN NOM TIEM
(more...)
Posted: November 10th, 2008
Categories:
amusing,
geeky,
lolcats,
ruby on rails
Comments:
View Comments.
Tonight i decided to write out "Mamma Mia" for my cousin whom i teach piano. I got out my pad of music lines, but hadn't even set pen to paper before thinking, "I hate doing this! I wonder if there's an open-source music notation package …"
One quick search later and i remembered LilyPond! A friend showed me this years ago, and i was really intrigued by it. As a programmer, this is very satisfying to me. You write your music as a kind of code, 'compile' it, and it outputs PDF, PS and, if you want it, a MIDI file.

We used to do this on Windows, with Cygwin. It is very pleasing to use it on its intended operating system now! :) It was easy to input, and i do love the pure geekiness of the notation! :D
Posted: September 22nd, 2008
Categories:
amusing,
geeky,
music,
open source,
ruby on rails
Comments:
View Comments.
Last night i severely messed up my computer trying to install the latest version of CouchDB. I ran into dependency troubles, and then i uninstalled some kind of essential packages that ended up removing all sorts of things that i rather wanted! But this is okay because i needed a push to move up to the new Debian. And i'm glad i did … Lenny looks nice so far! :)
So i am currently going through the process of installing Ruby on Rails. I've never managed to do this right first time, but i always learn a little bit more every time i try. Let's see if i can nail it this time.
(more…)
Posted: September 14th, 2008
Categories:
computer,
ruby on rails
Comments:
View Comments.
- An introduction to CouchDB
- Installing CouchDB
- Experimenting with CouchDB's web interface
- Integrating with Rails using ActiveCouch
- Integrating with Rails using RelaxDB
- Getting to scaffolding using RelaxDB
- Installing CouchDB from Subversion source code
- Trying out couchrest and topfunky’s basic_model
Okay, after my brief disappointment earlier, i've found a way that seems to work, at least for the time being. I have taken the RelaxDB lines out of environment.rb and put them into the application controller instead.
(more…)
Posted: September 12th, 2008
Categories:
couchdb,
ruby on rails
Comments:
View Comments.
I've had a really nice weekend: interesting and exciting, both of which are relative terms, i know!
Yesterday i made my own version of the Rails scaffold generator, featuring Low Pro to do as much as possible via AJAX. The JavaScript is completely unobtrusive, all done by Low Pro behaviours. It degrades gracefully for browsers without JavaScript. I have RSpec tests for the controller, too. It'll probably be available on GitHub soon … i just have to check with my boss that it's alright because we'll be using it at work.
Today i got a lot of chores done, which is a relief. Now i wouldn't be completely embarrassed if somebody were to spring a surprise visit on us! I wrote a review of RailsConf for our company blog, and i learnt more about CouchDB and made a decision to get Rails working with it.
I am grateful to have some friends on Twitter that i met at RailsConf, who are excited about CouchDB too. It feels as if i am getting involved in something that's going to be big and exciting, and i'm glad to be a part of it, even if it's just writing about my experiences. I am sure it must be possible to get Rails working on CouchDB … i just haven't managed to find any documentation to tell me how. I feel that is a space that i can fill! :)
Posted: September 7th, 2008
Categories:
couchdb,
ruby on rails
Comments:
View Comments.
- An introduction to CouchDB
- Installing CouchDB
- Experimenting with CouchDB's web interface
- Integrating with Rails using ActiveCouch
- Integrating with Rails using RelaxDB
- Getting to scaffolding using RelaxDB
- Installing CouchDB from Subversion source code
- Trying out couchrest and topfunky’s basic_model
This afternoon i decided that what the Internet really needs right now is some information about how to connect Ruby on Rails to a CouchDB database. So i'm going to have a go! I don't quite know what to do (which will probably become very clear!) so this will be a play-along-at-home experience. I'll blog about it in a series of posts, stopping whenever i get stuck. Hopefully i'll receive some feedback on whether what i'm doing is a good idea, and get some tips for what to try next.
This first post is just going to be an introduction, stating my interest in wanting to get this to work.
Some brief definitions
For those who don't know, here are some basic starting points …
Ruby is an open-source, interpreted, object-oriented programming language created by Yukihiro Matsumoto ('Matz').
Rails is a web application framework, created by David Heinemeier Hansson, written in Ruby, which guides us down an 'opinionated' route of best practices such as Model-View-Controller architecture, RESTful techniques, test/behaviour-driven-development. Thanks to its use of conventions rather than configuration, it is easy to get going quickly with Rails. However, it can be quite difficult to break out of the conventions, as we are going to try to do by using CouchDB as the database platform.
CouchDB, from what i can gather, is a document-oriented, RESTful, distributed database system written in Erlang.
Erlang is a programming language from Ericsson, which enables features such as concurrency, soft-real-time access, and fault-tolerance.
More technical details of CouchDB follow …
(more…)
Posted: September 7th, 2008
Categories:
couchdb,
ruby on rails
Comments:
View Comments.