Sunday, May 20, 2007

will_paginate




err the blog has a nice post about their enhancements to the will_paginate plugin.

Pagination will be removed from Rails 2.0, so now is a good time as any to move over to using more modern ways of paginating. I never really liked pagination in Rails, it didn't feel very slick.

The other thing that I really don't like with Rails, is the whole word choice of "has_one" and "belongs_to". Whenever I'm coding up a new project in Rails, I have to think hard if this is a "has_one" or a "belongs_to" relationship. The way I solve it is by thinking about where the foreign key should logically go, which is just ridiculous, because the ORM mapping of ActiveRecord is supposed to *help* me, not make things more complicated. Those words are just poorly chosen, and I think the problem is that the relationships we are mapping are more complicated than just a "has" and "belongs_to" relationship.

I think these words were chosen because they approximately map onto which table has the foreign key, the table with the "belongs_to" has the foreign key. Ok, that's easy enough to remember if you hammer it into your brain, but just doesn't seem to be the right choice of words.

You really see this when you start doing polymorphic associations and STI, where you pass in a parameter hash to the :belongs_to and :has_one methods. It starts getting really ugly and just doesn't map onto my mindspace about the problem.

We seriously need new words in ActiveRecord instead of "has_one", "has_many" and "belongs_to". Right now, they suck.