New in Rails: has_many :through gets :uniq

Posted by marcel May 08, 2006 @ 08:00 PM

Changset 4325 adds the :uniq option to has_many :through. Josh Susser, ActiveRecord associations guru, offers a nice write up of what it means for has_many :through to have :uniq.

You haven’t subscribed to Josh’s RSS feed yet?

Posted in Documentation | 5 comments

Comments

  1. Wibble on 08 May 20:19:

    Why :uniq rather than :unique ?

  2. Jeremy on 08 May 20:32:

    Because has_and_belongs_to_many already had a :uniq option named after Ruby’s Array#uniq. Perhaps :distinct is better.

  3. josh on 08 May 21:12:

    I like using the :uniq option name, as it is the same as the habtm feature and I think it makes sense for Ruby programmers. I’d keep the :distinct name in reserve for an option that uses the SQL DISTINCT feature to remove duplicates (I can dream, heh).

  4. Daniel Luz on 08 May 21:13:

    Just a note: Josh’s “RSS feed” is actually an ATOM feed :)

  5. BillyG on 08 May 21:34:

    I would if I could but I’m stuck with RSS in ATOM, guess it makes the Winer happy though lol.